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.

Restore fails with error NU1605 when RuntimeIdentifier is set and ProjectReference is used to netcoreapp2.1 project

See original GitHub issue

Repro repro.zip

Create two projects:

  • src/src.csproj
    • TargetFramework = netcoreapp2.1
    • RuntimeIdentifer = win-x64
  • test/test.csproj
    • TargetFramework = netcoreapp2.1
    • ProjectReference to src/src.sproj

Run dotnet restore with the 2.1.301 SDK or newer

Result Restore fails

/private/tmp/console1/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.  [/private/tmp/console1/console1.sln]
/private/tmp/console1/test/test.csproj : error NU1605:  test -> src -> Microsoft.NETCore.App (>= 2.1.1)  [/private/tmp/console1/console1.sln]
/private/tmp/console1/test/test.csproj : error NU1605:  test -> Microsoft.NETCore.App (>= 2.1.0) [/private/tmp/console1/console1.sln]
  Restore failed in 396.65 ms for /private/tmp/console1/test/test.csproj.

Workarounds

  • Add <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> to test.csproj ( suggested by @dsplaisted )
  • Add <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion> to test.csproj
  • Add <RuntimeIdentifier>win-x64</RuntimeIdentifier> and <OutputType>exe</OutputType> to test.csproj
  • Change <RuntimeIdentifier> to <RuntimeIdentifiers> (plural) in src.csproj

Details

.NET Core SDK (reflecting any global.json):
 Version:   2.1.301
 Commit:    59524873d6

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /Users/namc/.dotnet/sdk/2.1.301/

cc @dsplaisted

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
dsplaistedcommented, Jun 26, 2018

The workaround I would suggest is to set TargetLatestRuntimePatch to true in the test project.

Some related info: https://docs.microsoft.com/en-us/dotnet/core/deploying/runtime-patch-selection

1reaction
natemcmastercommented, Jun 26, 2018

One more idea: what if we set PrivateAssets=All even when OutputType == exe? Based on this comment, it seems like we don’t generally need Microsoft.NETCore.App in the .nuspec with the notable exception (and edge case) of '$(PackageType)' == 'DotnetCliTool'

https://github.com/dotnet/sdk/blob/1512386f2c279f2146d7c58cecde989bc2ec9176/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props#L51-L56

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error NU1605 Detected package downgrade
I had a similar issue with a .netcoreapp2.2 console application. The project was building successfully. However, publishing was failing with ...
Read more >
NuGet Warning NU1605
While NU1605 is considered a warning by the NuGet tooling, the .NET SDK opts into treating this warning as an error through WarningsAsErrors...
Read more >
[NU1605] Detected package downgrade: … Reference the ...
For me the Solution it happened with had a number of projects, it also had a packages folder. The first step was to...
Read more >
DotNet core builds nolonger work on hosted agent (nuget ...
NU1605 : Detected package downgrade: Microsoft.NETCore.App from 2.0.7 to 2.0.0. Reference the package directly from the project to select a ...
Read more >
45qpzbpjr65v.txt
The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead...
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