I try to update my .net solution from .NET Core 1.1 to .NET Core 2.1. I have several .NET Core and .NET standard projects inside, which reference each other and another NuGet packages. After update 'dotnet resore' and 'dotnet build' commands work fine, but when i try to build my solution from visual studio, i get this error:
Error NU1605 Detected package downgrade: Microsoft.NETCore.App from 2.1.3 to 2.1.0. Reference the package directly from the project to select a different version.
And i see that indeed some of my projects have SDK reference to Microsoft.NETCore.App v2.1.0 and some of them v.2.1.3. Setting RuntimeFrameworkVersion and adding this package to dependencies explicitly doesn't work.
How i can deal with this?
UPD: dotnet --info:
.NET Core SDK (reflecting any global.json): Version: 2.1.401 Commit: 91b1c13032
Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.401\
Host (useful for support): Version: 2.1.3 Commit: 124038c13e
.NET Core SDKs installed:
1.1.10 [C:\Program Files\dotnet\sdk]
2.0.0 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.100 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App
1.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App
2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App
2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App
2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
UPD: Somehow issue disappears if i remove this line from .csproj file:
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
Can it be related?
I had this issue as well. What ultimately fixed it for me was uninstalling the .NET SDK 2.1.3 from the "Programs" control panel. Or I basically had to uninstall any later versions of the related SDK libraries that my project was trying to use.
After updating .net core SDK on my windows machine from .net core 2.1.0 to .net core 2.2.0 I had the same issue. I was unable to build the project and getting build error with Detected package downgrade: Microsoft.AspNetCore.Razor.Design from 2.2.0 to 2.1.0.
I have resolved this issue by updating a nuget package for Microsoft.AspNetCore.Razor.Design
I also had this problem after installing a new version of .Net Core (2.0 to 2.1). The below link gave me a hint of what caused the problem.
https://github.com/dotnet/cli/issues/9433
The solution for me was to change the project's Target Framework to the latest installed .Net Core version.
I had a missing version in the csproj file.
Adding the version fixed the issue.
For future readers.
So early in the morning, my code was building.
Then I started getting this error:
and I got it on 2 assemblies,csprojs.
So of course, I started tracking down "Microsoft.Extensions.Logging".
But then I remembered "It was working this morning", and I back tracked my changes.
I found a new package (nuget import) add in
(and ONE and TWO had a reference to THREE)
Here was the "new" line:
So I looked and looked, but this was the ONLY place "Microsoft.Extensions.Http" package was being imported.
Do what?
From memory, I just kinda remembered that I had alot of "3.1.0" package imports, but no 3.1.1.
examples of OTHER package imports (for example):
Long story:short..............I changed that new package import (the new import was the prime-suspect in my code breakage)...and changed it to to match the "3.1.0 world".
So I now had this.
And now everything works.
So the (actual) error could be a red-herring to what is actually happening.
Hopefully you're using source control, and can "reverse" step it.
Just to finish this out...here is the the weird part:
I opened up this file.
and it references
Not, it is "3.1.0\Microsoft.Extensions.Logging.dll". So what is it breaking stuff????? (Who knows?)
so while it doesn't make sense to me...........what I showed above did address the issue.
Go figure.
Hope that helps someone.
My version of this issue (I think) was caused by a combination of actual .NET Core versions installed on a Jenkins build server alongside a Unit Test project having ambigious references.
I understand that, in an ideal world, dotnet expects no version stated in the csproj for AspNetCore - providing maximum flexibility during build:
However, on the build server when it compiled the main project (first), it chose to use 2.1.6 as the AspNetCore version. It then tries to compile the test project, and that project had a minimum version of "2.1.1", so build process tries to downgrade and then aborts the build as a fail.
I removed the "2.1.1" minimum version from the test project, but then the test project would not build locally because it could not resolve the dependencies unambigiously. After a number of NuGet package upgrades / downgrades no joy, so chose to force a "2.1.6" minimum version so align with build server.
This still could not resolve locally all the dependencies correctly, and finally ended up with forcing the minimum version for NetCore as well:
Everything now built locally and on the Jenkins build server!