Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Net Core 2.0 projects after installing Net Core 2.1 #9473

Closed
adrian-lopez-softtek opened this issue Jun 7, 2018 · 6 comments
Closed
Assignees
Milestone

Comments

@adrian-lopez-softtek
Copy link

After installing .Net Core 2.1, console projects targeting Net Core 2.0 that have <RuntimeIdentifier>win7-x64</RuntimeIdentifier>, have a higher version of Microsoft.NETCore.App nuget package (2.0.7). If you create a class library project that references the console one, for example a test project, it complains about package downgrading, as Microsoft.NETCore.App nuget package for class library project has version 2.0.0.

Adding <RuntimeFrameworkVersion>2.0.7</RuntimeFrameworkVersion> and <RuntimeIdentifier>win7-x64</RuntimeIdentifier> to class library csproj seems a way of overcoming this issue, but I am not sure if it's the most correct one.

Steps to reproduce

Install .Net Core 2.1
Clone https://github.com/adrian-lopez-softtek/RuntimeIdentifierIssue and try to build it

Expected behavior

Project builds fine

Actual behavior

Error 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 different version.

Environment data

dotnet --info output:

 .NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  1.0.0 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.0-preview2-006497 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.100 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007589 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0-preview2-25407-01 [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.3 [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.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download 

Thank you!

@livarcocc
Copy link
Contributor

The workaround you mention is correct.

This is a dup of #2312.

@dasMulli
Copy link
Contributor

dasMulli commented Jun 7, 2018

@livarcocc I'm not sure this is a dupe of #2312

#2312 seems to have a problem because the plural RuntimeIdentifiers is used for the -r argument to restore, which does not trigger the self-contained roll-forward logic (NuGet doesn't re-evaluate the project for reach RID in RuntimeIdentifiers).

This issue is caused by the test project being turned into <OutputType>Exe</OutputType> by the test SDK NuGet after the SDK targets ran their logic and self-contained roll-forward logic is not run for this exe even if RuntimeIdentifier is set in the test project file.

@livarcocc
Copy link
Contributor

@dsplaisted please take a look.

@livarcocc livarcocc reopened this Jun 7, 2018
@dsplaisted dsplaisted self-assigned this Jun 11, 2018
@neilsimp1
Copy link

Removing <OutputType>Exe</OutputType> from the .csproj for a class library did the trick for me.

@livarcocc
Copy link
Contributor

ping @dsplaisted

@dsplaisted
Copy link
Member

This looks like a different case of the same underlying issue as #2312. They should both be fixed in 2.2.100 by #2395.

In the meantime, the workaround I would suggest is to add the following property to the test project:

<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 3.0.1xx milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants