Error NU1605 Detected package downgrade
Solution 1:
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)
Solution 2:
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.
Solution 3:
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.
Solution 4:
All of the above did not help me with my .NET Core 3.1 project.
The error NU1605 reappeared again and again after complete recompilation. All references to the version number have been correct in the csproj file.
What finally helped was to delete the obj folder!
Afterwards the recompilation worked without problems.