Detected package downgrade: Microsoft.NETCore.App from 2.1.1 to 2.1.0. Reference the package directly from the project to select a different version.
I'm unable to get my solution to build due to an issue with a unit test project which references my service project forcing a package downgrade of my service project from 2.1.1 down to 2.1.0
No where have I explicitly set the dotnet core revision, and my netcoreapp projects are all 2.1
Prior to me installing dotnetcore 2.1.301, I had the 2.1.3 (RC1) and everything worked just fine.
I'm unable to manually change the version of the unit test project from 2.1.0 to 2.1.1, and doing doing a install package microsoft.netcore.app -version 2.1.1 does not fix the issue either.
I can set <TargetLatestRuntimePatch>false</TargetLatestRuntimePatch> in the service project, and this does resolve the problem, however I'm not happy having to do this in a production service which is being worked on by a team of developers.
dotnet --version
2.1.301
Service fabric service project

Service unit test project

Service unit test project nuget package manager

Seeing the same in my project with xUnit when specifying runtime when building. Repro:
> dotnet --version
2.1.301
mkdir 211_210
cd 211_210
mkdir mvc
cd mvc
dotnet new mvc
cd ..
mkdir test
cd test
dotnet new xunit
dotnet add reference ../mvc/mvc.csproj
dotnet build -r any
Produces the following output:
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for C:\Users\agr\Source\Repos\211_210\test\test.csproj...
Restoring packages for C:\Users\agr\Source\Repos\211_210\mvc\mvc.csproj...
Restore completed in 46.55 ms for C:\Users\agr\Source\Repos\211_210\test\test.csproj.
C:\Users\agr\Source\Repos\211_210\test\test.csproj : error NU1605: Detected package downgrade: Microsoft.NETCore.App from 2.1.1 to 2.1.0. Reference the package directly from the project to select a different version.
C:\Users\agr\Source\Repos\211_210\test\test.csproj : error NU1605: test -> mvc -> Microsoft.NETCore.App (>= 2.1.1)
C:\Users\agr\Source\Repos\211_210\test\test.csproj : error NU1605: test -> Microsoft.NETCore.App (>= 2.1.0)
Restore failed in 294.47 ms for C:\Users\agr\Source\Repos\211_210\test\test.csproj.
Restore completed in 629.54 ms for C:\Users\agr\Source\Repos\211_210\mvc\mvc.csproj.
Build FAILED.
C:\Users\agr\Source\Repos\211_210\test\test.csproj : error NU1605: Detected package downgrade: Microsoft.NETCore.App from 2.1.1 to 2.1.0. Reference the package directly from the project to select a different version.
C:\Users\agr\Source\Repos\211_210\test\test.csproj : error NU1605: test -> mvc -> Microsoft.NETCore.App (>= 2.1.1)
C:\Users\agr\Source\Repos\211_210\test\test.csproj : error NU1605: test -> Microsoft.NETCore.App (>= 2.1.0)
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.03
Just dotnet build seems to work, but if any runtime is specified it fails. I tried any, win, win-x64, linux-x64. Same happens both in Linux and Windows. It worked (and still works) fine in 2.1.300.
This probably requires a fix in the templates or the SDK? (SDK team?)
MVC wants 2.1.1 of NetCoreApp
Unit test projects wants 2.1.0 of NetCoreApp.
Normally, this is a NuGet warning, but SDK projects have turned NU1605 into an error on purpose (Warning as Error).
My guess is that this should be closed, in favor of the following info I got from @dsplaisted in email:
This is part of a class of issues we have. If a RID is specified, and the project is an Exe, then by default we鈥檒l use the latest patch of Microsoft.NETCore.App. We run into issues when you reference a project that uses the latest patch from one that doesn鈥檛.
Other related issues:
https://github.com/dotnet/sdk/issues/2364
https://github.com/dotnet/sdk/issues/2253
Issue moved to dotnet/cli #9624 via ZenHub
I too am frustrated by this issue.
Very frustrating
Why was this closed if it wasn't fixed?
I am also experiencing this issue in VSTS. This is preventing our builds from completing and as others have said, is very frustrating.
@Cloudmersive the issue was NOT closed as Won't Fix -- it was MOVED to another repo: https://github.com/dotnet/cli/issues/9624 (see https://github.com/dotnet/core/issues/1754#issuecomment-403620515)
@haydenhancock I would suggest to check solutions & workarounds in the CLI repo issue (or add comments there if needed).
@karelz I've tried all the suggested fixes and nothing worked for me. What's interesting is that my build pipeline (with no code changes or build pipeline changes) was working without issue yesterday.
@haydenhancock those are good things to raise on the open CLI issue. This issue is closed and further discussion here is not reaching the right experts.
Most helpful comment
I too am frustrated by this issue.