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

Unexpected NU1605 from transitive reference that was never selected (pruned subgraph) #10972

Closed
madelson opened this issue Jun 25, 2021 · 5 comments · Fixed by NuGet/NuGet.Client#4128
Assignees
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Style:PackageReference Type:Bug

Comments

@madelson
Copy link

Details about Problem

NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe): NuGet CLI 5.9.1, VS 16.10.2

Repro steps and/or sample project

Using the provided solution:

ReproUnexpectedNU1605.zip

  • Build projects ReproPackageCV1 and ReproPackageCV2 -> copy .nupkgs to local feed
  • Build projects ReproPackageA and ReproPackageB -> copy .nupkgs to local feed
  • Run nuget restore -ForceEvaluate ReproUnexpectedNU1605.sln -> fails with

Errors in C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\Repro.csproj
NU1605: Detected package downgrade: System.Memory from 4.5.4 to 4.5.2. Reference the package directly from the project to select a different version.
Repro -> ReproPackageA 1.0.0 -> ReproPackageC 1.0.0 -> Microsoft.Extensions.Configuration 5.0.0 -> Microsoft.Extensions.Primitives 5.0.0 -> System.Memory (>= 4.5.4)
Repro -> System.Memory (>= 4.5.2)

High level description

  • In this project we reference 2 packages A and B as well as System.Memory 4.5.2.
  • A references C >= 1.0 and B references C >= 1.1.
  • C 1.0 references Microsoft.Extensions.Configuration 5.0 which ultimately requires System.Memory 4.5.4
  • C 1.1 references Microsoft.Extensions.Configuration 3.11.1 which ultimately requires System.Memory 4.5.2

When restoring, as you'd expect it NuGet resolves C 1.1. HOWEVER, it then complains that the direct reference to System.Memory 4.5.2 is incompatible with the chain of references coming from C 1.0. This feels like a bug to me (but also maybe I'm misunderstanding some nuance of the restore logic?).

Verbose Logs

$ nuget restore -verbosity detailed -forceevaluate ReproUnexpectedNU1605.sln && echo success
NuGet Version: 5.9.1.11
MSBuild auto-detection: using msbuild version '16.10.2.30804' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\msbuild.exe "C:\Users\madelson\AppData\Local\Temp\NuGetScratch\yk0lrx2b.tff.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\madelson\AppData\Local\Temp\NuGetScratch\4hpulsil.cl4.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="C:\NuGet\NuGet.exe" /p:RestoreSolutionDirectory="C:\users\madelson\source\repos\ReproUnexpectedNU1605\" /p:SolutionDir="C:\users\madelson\source\repos\ReproUnexpectedNU1605\" /p:SolutionName="ReproUnexpectedNU1605"

Running restore with 16 concurrent jobs.
Reading project file C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\ReproPackageCV1_1.csproj.
Reading project file C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\ReproPackageA.csproj.
Reading project file C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\ReproPackageB.csproj.
Reading project file C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\Repro.csproj.
Reading project file C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\ReproPackageCV1.csproj.
Restoring packages for C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\Repro.csproj...
Restoring packages for C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\ReproPackageCV1.csproj...
Restoring packages for C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\ReproPackageA.csproj...
Restoring packages for C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\ReproPackageCV1_1.csproj...
Restoring packages for C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\ReproPackageB.csproj...
Restoring packages for .NETStandard,Version=v2.0...
Restoring packages for .NETStandard,Version=v2.0...
Restoring packages for .NETStandard,Version=v2.0...
Restoring packages for .NETStandard,Version=v2.0...
Restoring packages for .NETStandard,Version=v2.0...
Resolving conflicts for .NETStandard,Version=v2.0...
Resolving conflicts for .NETStandard,Version=v2.0...
Resolving conflicts for .NETStandard,Version=v2.0...
Resolving conflicts for .NETStandard,Version=v2.0...
Resolving conflicts for .NETStandard,Version=v2.0...
Checking compatibility of packages on .NETStandard,Version=v2.0.
Checking compatibility of packages on .NETStandard,Version=v2.0.
Checking compatibility of packages on .NETStandard,Version=v2.0.
Checking compatibility of packages on .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageA 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for NETStandard.Library 2.0.3 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageB 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for NETStandard.Library 2.0.3 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageC 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageC 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageC 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.NETCore.Platforms 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration.Abstractions 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Primitives 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Buffers 4.5.1 with .NETStandard,Version=v2.0.
Checking compatibility for System.Memory 4.5.4 with .NETStandard,Version=v2.0.
Checking compatibility for System.Runtime.CompilerServices.Unsafe 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Numerics.Vectors 4.4.0 with .NETStandard,Version=v2.0.
All packages and projects are compatible with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageC 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for NETStandard.Library 2.0.3 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration.Abstractions 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.NETCore.Platforms 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for NETStandard.Library 2.0.3 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration.Abstractions 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration.Abstractions 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Primitives 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.NETCore.Platforms 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Primitives 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for System.Memory 4.5.2 with .NETStandard,Version=v2.0.
Checking compatibility for System.Runtime.CompilerServices.Unsafe 4.7.1 with .NETStandard,Version=v2.0.
Checking compatibility for System.Buffers 4.4.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Numerics.Vectors 4.4.0 with .NETStandard,Version=v2.0.
All packages and projects are compatible with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Primitives 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.NETCore.Platforms 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Buffers 4.5.1 with .NETStandard,Version=v2.0.
Checking compatibility for System.Memory 4.5.4 with .NETStandard,Version=v2.0.
Checking compatibility for System.Runtime.CompilerServices.Unsafe 5.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Numerics.Vectors 4.4.0 with .NETStandard,Version=v2.0.
All packages and projects are compatible with .NETStandard,Version=v2.0.
Checking compatibility for System.Memory 4.5.2 with .NETStandard,Version=v2.0.
Checking compatibility for System.Runtime.CompilerServices.Unsafe 4.7.1 with .NETStandard,Version=v2.0.
Checking compatibility for System.Buffers 4.4.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Numerics.Vectors 4.4.0 with .NETStandard,Version=v2.0.
All packages and projects are compatible with .NETStandard,Version=v2.0.
NU1605: Detected package downgrade: System.Memory from 4.5.4 to 4.5.2. Reference the package directly from the project to select a different version.
Repro -> ReproPackageA 1.0.0 -> ReproPackageC 1.0.0 -> Microsoft.Extensions.Configuration 5.0.0 -> Microsoft.Extensions.Primitives 5.0.0 -> System.Memory (>= 4.5.4)
Repro -> System.Memory (>= 4.5.2)
Checking compatibility of packages on .NETStandard,Version=v2.0.
Checking compatibility for Repro 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for NETStandard.Library 2.0.3 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageA 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageB 1.0.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Memory 4.5.2 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.NETCore.Platforms 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for ReproPackageC 1.1.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Buffers 4.4.0 with .NETStandard,Version=v2.0.
Checking compatibility for System.Numerics.Vectors 4.4.0 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Configuration.Abstractions 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for Microsoft.Extensions.Primitives 3.1.11 with .NETStandard,Version=v2.0.
Checking compatibility for System.Runtime.CompilerServices.Unsafe 4.7.1 with .NETStandard,Version=v2.0.
All packages and projects are compatible with .NETStandard,Version=v2.0.
Committing restore...
Committing restore...
Committing restore...
Committing restore...
Committing restore...
Generating MSBuild file C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\obj\ReproPackageB.csproj.nuget.g.props.
Generating MSBuild file C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\obj\Repro.csproj.nuget.g.props.
Generating MSBuild file C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\obj\ReproPackageCV1_1.csproj.nuget.g.props.
Generating MSBuild file C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\obj\ReproPackageCV1.csproj.nuget.g.props.
Generating MSBuild file C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\obj\ReproPackageA.csproj.nuget.g.props.
Assets file has not changed. Skipping assets file writing. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\obj\project.assets.json
Assets file has not changed. Skipping assets file writing. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\obj\project.assets.json
Writing cache file to disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\obj\project.nuget.cache
Writing cache file to disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\obj\project.nuget.cache
Writing cache file to disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\obj\project.nuget.cache
Writing cache file to disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\obj\project.nuget.cache
Writing assets file to disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\obj\project.assets.json
Persisting dg to C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\obj\ReproPackageCV1_1.csproj.nuget.dgspec.json
Persisting dg to C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\obj\ReproPackageA.csproj.nuget.dgspec.json
Persisting dg to C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\obj\ReproPackageB.csproj.nuget.dgspec.json
Persisting dg to C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\obj\ReproPackageCV1.csproj.nuget.dgspec.json
Restored C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1\ReproPackageCV1.csproj (in 501 ms).
Restored C:\users\madelson\source\repos\ReproUnexpectedNU1605\ReferencedV1_1\ReproPackageCV1_1.csproj (in 501 ms).
Restored C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageB\ReproPackageB.csproj (in 501 ms).
Restored C:\users\madelson\source\repos\ReproUnexpectedNU1605\PackageA\ReproPackageA.csproj (in 504 ms).
Writing cache file to disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\obj\project.nuget.cache
Writing packages lock file at disk. Path: C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\packages.lock.json
Persisting dg to C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\obj\Repro.csproj.nuget.dgspec.json
Failed to restore C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\Repro.csproj (in 502 ms).

Errors in C:\users\madelson\source\repos\ReproUnexpectedNU1605\Repro\Repro.csproj
NU1605: Detected package downgrade: System.Memory from 4.5.4 to 4.5.2. Reference the package directly from the project to select a different version.
Repro -> ReproPackageA 1.0.0 -> ReproPackageC 1.0.0 -> Microsoft.Extensions.Configuration 5.0.0 -> Microsoft.Extensions.Primitives 5.0.0 -> System.Memory (>= 4.5.4)
Repro -> System.Memory (>= 4.5.2)

NuGet Config files used:
C:\Users\madelson\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
C:\LocalNugetRepo
https://www.nuget.org/api/v2/

@nkolev92
Copy link
Member

Thanks for the great repro!

This looks like a bug, as the error is not very helpful because the subgraph has been pruned.

I tweaked your repro a bit to allow it to be runnable with a single script, https://github.com/nkolev92/NU1605ReportedForPrunedSubgraph-10972.

@nkolev92 nkolev92 added Area:ErrorHandling warnings and errors/log messages & related error codes. Functionality:Restore Type:Bug Style:PackageReference labels Jun 26, 2021
@nkolev92 nkolev92 changed the title Unexpected NU1605 from transitive reference Unexpected NU1605 from transitive reference that was never selected (pruned subgraph) Jun 26, 2021
@zkat zkat added Category:Quality Week Issues that should be considered for quality week Priority:2 Issues for the current backlog. labels Jun 28, 2021
@nkolev92 nkolev92 self-assigned this Jun 29, 2021
@nkolev92 nkolev92 added this to the Sprint 2021-06 milestone Jun 29, 2021
@madelson
Copy link
Author

@nkolev92 great to see movement here; do you know which NuGet client release would have the fix?

@nkolev92
Copy link
Member

The fix would be in 6.0, both NuGet 6.0 and .NET SDK 6.0.1xx

@madelson
Copy link
Author

Great! Any chance of a prerelease package on NuGet.org before then?

@nkolev92
Copy link
Member

The restore build tasks can't really ship as a package, but there are a few other ways to dogfood:

  • NuGet.exe previews.
  • dotnet.exe nightlies (dotnet.exe public previews)
  • Visual Studio previews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Style:PackageReference Type:Bug
Projects
None yet
3 participants