Error NU1605 Detected package downgrade

前端 未结 5 1544
野趣味
野趣味 2021-02-11 12:00

I am experiencing the following NU1605 dependency errors in my netcoreapp2.0 console application:

NU1605  Detected package downgrade: System.Dia         


        
相关标签:
5条回答
  • 2021-02-11 12:30

    I had a similar issue with a .netcoreapp2.2 console application.

    The project was building successfully. However, publishing was failing with several NU1605 errors.

    The problem was originated from log4net version 2.0.8. It was referenced in a .netstandard2.0 project with the following dependencies:

    They were causing package downgrades in the projects referencing log4net. And during publish these warnings are treated as errors...

    To solve the problem I added correct versions of these libraries via Nuget.

    Finally, the publishing succeeded.

    P.S. When I first added packages with the newest version of libraries, a yellow warning sign was displayed on the dependencies list as if the packages were not suitable for that project. After unloading the project and loading back the warning sign gone! (I'm using Visual Studio 2019)

    Hope it helps!

    0 讨论(0)
  • 2021-02-11 12:33

    Error NU1605 Detected package downgrade

    For the error NU1605:

    You can use <NoWarn>NU1605</NoWarn> to clear the WarningsAsErrors in your project.

    That because netcoreapp2.0 projects have <WarningsAsErrors>NU1605</WarningsAsErrors> by default. Check it from Properties->Build->Treat warning as errors:

    Add like following:

    <PackageReference Include="Colorful.Console" Version="1.2.6">
          <NoWarn>NU1605</NoWarn>
    </PackageReference>
    

    Check the blog post here: MSBuild integration of NuGet warnings and errors and Unexpected package version warnings.

    For the error NU1603:

    The warning occurs because System.Runtime.Handles (>= 4.1.0) does not exist in the feed. Typically this is a package authoring error because the package depends on something that doesn't exist.

    You can also use <NoWarn>NU1603</NoWarn> to resolve this issue:

    <PropertyGroup>
          <NoWarn>NU1603</NoWarn>
    </PropertyGroup>
    

    Note:You would notice that your project has another warning, notice the yellow triangle insignia on the PackageReference DotSpinners on Reference. That because the package DotSpinners is a .NET Framework project, not compatible with your .NET Core project.

    Hope this helps.

    0 讨论(0)
  • 2021-02-11 12:35

    Something that I've run into that causes this error is having multiple references to the same package in one or more .csproj files. In our case, these references are to local dependencies in our own nuget repository.

    This is invisible to a developer in Visual Studio, so you need to open the .csproj file in a separate editor.

    For my team, I think the cause is a combo of a lot of churn in both a dependent library and the solution that consumes that dependency. For whatever reason, a git merge will take both versions in the .csproj file without raising a conflict. In several project files, I found 3 versions of the same dependency.

    0 讨论(0)
  • 2021-02-11 12:49

    Just had the same issue (NU1605) with .Net core 3.1 and log4Net:

    error NU1605: Detected package downgrade: System.Net.NameResolution from 4.3.0 to 4.0.0.

    What I did is adding a Nuget reference to System.Net.NameResolution and install version 4.3.0, then I closed Visual Studio and re-opened the Solution.

    0 讨论(0)
  • 2021-02-11 12:50

    Make sure that you are using same version for build and publish you can fix it adding 2.1.9 in .csproj file under PropertyGroup this should match with your current settings version. Ex:

      <PropertyGroup>
          <OutputType>Exe</OutputType>
          <TargetFramework>netcoreapp2.1</TargetFramework>    
          <RuntimeFrameworkVersion>2.1.9</RuntimeFrameworkVersion> 
      </PropertyGroup>
    

    Error which I got was: NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.9, but with current settings, version 2.1.0 would be used instead.

    0 讨论(0)
提交回复
热议问题