question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NetCoreApp2.1 using SDK 2.1.1 package downgrade to 2.1.0

See original GitHub issue

@grantwar commented on Wed Jul 04 2018

Service Fabric Service using SDK 2.1.1 has an associated test core 2.1 project which is showing up as using SDK 2.1.0, won’t allow me to upgrade via nuget (Blocked by project).

Build Error

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.

Issue

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.

Setup

dotnet --version

2.1.301

Service fabric service project image

Service unit test project image

Service unit test project nuget package manager image


@agr commented on Wed Jul 04 2018

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.


@rrelyea commented on Fri Jul 06 2018

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).


@rrelyea commented on Fri Jul 06 2018

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’ll 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’t.

Other related issues: https://github.com/dotnet/sdk/issues/2364 https://github.com/dotnet/sdk/issues/2253

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
dsplaistedcommented, Aug 23, 2018

I believe this will be fixed in 2.2.100 by https://github.com/dotnet/sdk/pull/2395.

Until then, an alternative workaround which doesn’t involve modifying the production project is to put <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> in your test project.

4reactions
beefocommented, Aug 27, 2018

Worked for me when I added <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> to both parent and unit test projects. Adding to test project alone did not work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detected package downgrade: Microsoft.NETCore.App ...
After that line was added the project would publish correctly. The below link references a downgrade issue between 2.1.1 and 2.1.0 but the ......
Read more >
Migrate from ASP.NET Core 2.1 to 2.2
This article outlines the prerequisites and most common steps for migrating an ASP.NET Core 2.1 project to ASP.NET Core 2.2.
Read more >
NuGet Warning NU1605
1. In this case, the downgrade message will have a package starting with runtime.<RID> in the dependency chain. Solution.
Read more >
The mystery of package downgrade issue
Naturally, very first build failed. The issue. Compilation error said that Detected package downgrade: Microsoft.NETCore.App from 2.1.1 to 2.1.0 ...
Read more >
Making sense of ASP.NET Core Metapackage Versioning
Detected package downgrade: Microsoft.AspNetCore.App from 2.1.4 to 2.1.0. Reference the package directly from the project to select a different ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found