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

NuGet raises NU1201 compatibility error in projects that reference both a project and a package (transitively) with the same identity for different TFMs #10617

Closed
ViktorHofer opened this issue Mar 3, 2021 · 4 comments

Comments

@ViktorHofer
Copy link

ViktorHofer commented Mar 3, 2021

Details about Problem

NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe): dotnet.exe

Product version: 5.0.100 / 6.0 Preview 1

Worked before? If so, with which NuGet version:

Repro steps and/or sample project

A project which references another project with the same identity as a transitive package reference causes NuGet's compatibility check to fail and believe that the supported tfms of the project apply to the package as well. That happens even if the both references are condition on different TargetFrameworks.

In this case we have a parent project called parent.csproj which multi-targts for net5.0 and netstandard2.0 and references a child project child1.csproj on netstandard2.0 which itself package references System.Memory which itself again has a package dependency on System.Numerics.Vectors. The System.Numerics.Vectors package supports i.e. netstandard2.0 but not net5.0. The parent project also references another project on net5.0 called System.Numerics.Vectors which supports net5.0. The same identities cause NuGet to throw a NU1201.

parent (project) netstandard2.0 TFM --> child1 (project) --> System.Memory (package) --> System.Numerics.Vectors (package)
                 net5.0 TFM --> System.Numerics.Vectors (project)
  1. Download and unzip nugetnodes.zip
  2. dotnet restore nugetnodes\parent\parent.csproj

Verbose Logs

C:\temp\nugetnodes\parent>dotnet restore
  Determining projects to restore...
C:\temp\nugetnodes\parent\parent.csproj : error NU1201: Project System.Numerics.Vectors is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project System.Numerics.Vectors supports: net5.0 (.NETCoreApp,Version=v5.0)
  Restored C:\temp\nugetnodes\child1\child1.csproj (in 276 ms).
  Failed to restore C:\temp\nugetnodes\parent\parent.csproj (in 276 ms).

cc @nkolev92 @rrelyea @safern @ericstj

@ViktorHofer ViktorHofer changed the title NuGet raises NU1201 compatibility error in projects that reference both a project and a package (transitively) with the same identity NuGet raises NU1201 compatibility error in projects that reference both a project and a package (transitively) with the same identity for different TFMs Mar 4, 2021
@nkolev92
Copy link
Member

nkolev92 commented Mar 9, 2021

A project which references another project with the same identity as a transitive package reference

Without digging further, NuGet should select the project if the project & package have the same version.
Do you see the package getting selected in a graph where both are available?
If not, then this is likely by design.

@erdembayar
Copy link
Contributor

I'm closing this one because it's duplicate of #10368
Please go there and upvote.

@ViktorHofer
Copy link
Author

Without digging further, NuGet should select the project if the project & package have the same version.

This issue is about NuGet selecting the project over the package even though the project isn't referenced by a specific TFM when multi-targeting.

@nkolev92
Copy link
Member

yeah @erdembayar is on hot seat this week so he correctly validated that it's a bug similar to the one we reported in #10368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants