NuGet Product Used
NuGet.exe
Product Version
6.2.1.2 and also 6.2.1.7 from dotnet
Worked before?
No response
Impact
I'm unable to use this version
Repro Steps & Context
Context
Let's have project with following structure:
Net46Reference - a SDK-style project targeting net46, producing a library.
Net6Root - a SDK-style project targeting net6, producing a library.
Net6Root references Net46Reference
Steps to reproduce
- Clone minimal reproducer from https://github.com/pavel-mikula-sonarsource/Repro_NU1004
- Run
nuget restore Repro_NU1004.sln -LockedMode
Reproducer projects are almost empty without nuget references. They have different target frameworks and reference each other.
Actual behavior
Error is produced:
NU1004: The project Net46Reference has no compatible target framework. The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.
Expected behavior
nuget restore should work and should not emit NU1004. Just as it works when running without -LockedMode argument.
Regression?
While it isn't exactly the same, the behavior looks similar to #9623
Verbose Logs
NuGet Version: 6.2.1.2
MSBuild auto-detection: using msbuild version '17.2.1.25201' from 'c:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
c:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\msbuild.exe "C:\Users\xxxxx\AppData\Local\Temp\NuGetScratch\31zoivzd.1te.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\xxxx\AppData\Local\Temp\NuGetScratch\ea21zcpt.sml.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="c:\Apps\Nuget\nuget.exe" /p:RestoreSolutionDirectory="d:\xxxx\Repro_NU1004\\" /p:SolutionDir="d:\xxxx\Repro_NU1004\\" /p:SolutionName="Repro_NU1004" /p:RestoreLockedMode="True"
Running restore with 16 concurrent jobs.
Reading project file d:\xxxx\Repro_NU1004\Net46Reference\Net46Reference.csproj.
Reading project file d:\xxxx\Repro_NU1004\Net6Root\Net6Root.csproj.
The restore inputs for 'Net46Reference' have not changed. No further actions are required to complete the restore.
The restore inputs for 'Net6Root' have changed. Continuing restore.
Committing restore...
Assets file has not changed. Skipping assets file writing. Path: d:\xxxx\Repro_NU1004\Net46Reference\obj\project.assets.json
No-Op restore. The cache will not be updated. Path: d:\xxxx\Repro_NU1004\Net46Reference\obj\project.nuget.cache
Restored d:\xxxx\Repro_NU1004\Net46Reference\Net46Reference.csproj (in 63 ms).
NU1004: The project Net46Reference has no compatible target framework. The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.
Checking compatibility of packages on net6.0.
All packages and projects are compatible with net6.0.
Skipping the lock file regeneration for 'd:\xxxx\Repro_NU1004\Net6Root\packages.lock.json'.
Committing restore...
Generating MSBuild file d:\xxxx\Repro_NU1004\Net6Root\obj\Net6Root.csproj.nuget.g.props.
Assets file has not changed. Skipping assets file writing. Path: d:\xxxx\Repro_NU1004\Net6Root\obj\project.assets.json
Writing cache file to disk. Path: d:\xxxx\Repro_NU1004\Net6Root\obj\project.nuget.cache
Persisting dg to d:\xxxx\Repro_NU1004\Net6Root\obj\Net6Root.csproj.nuget.dgspec.json
Failed to restore d:\xxxx\Repro_NU1004\Net6Root\Net6Root.csproj (in 176 ms).
Errors in d:\xxxx\Repro_NU1004\Net6Root\Net6Root.csproj
NU1004: The project Net46Reference has no compatible target framework. The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.
NuGet Config files used:
C:\Users\xxxx\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
https://api.nuget.org/v3/index.json
1 of 2 projects are up-to-date for restore.
NuGet Product Used
NuGet.exe
Product Version
6.2.1.2 and also 6.2.1.7 from dotnet
Worked before?
No response
Impact
I'm unable to use this version
Repro Steps & Context
Context
Let's have project with following structure:
Net46Reference- a SDK-style project targetingnet46, producing a library.Net6Root- a SDK-style project targetingnet6, producing a library.Net6RootreferencesNet46ReferenceSteps to reproduce
nuget restore Repro_NU1004.sln -LockedModeReproducer projects are almost empty without nuget references. They have different target frameworks and reference each other.
Actual behavior
Error is produced:
Expected behavior
nuget restoreshould work and should not emit NU1004. Just as it works when running without-LockedModeargument.Regression?
While it isn't exactly the same, the behavior looks similar to #9623
Verbose Logs