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

Exception while restoring: "Restore metadata is mising the required target frameworks list" #10924

Closed
ps-weber opened this issue Jun 7, 2021 · 17 comments · Fixed by NuGet/NuGet.Client#4127
Assignees
Labels
Area:RestoreRepeatableBuild The lock file features Priority:1 High priority issues that must be resolved in the current sprint. RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Triage:NeedsTriageDiscussion Type:Bug

Comments

@ps-weber
Copy link

ps-weber commented Jun 7, 2021

Details about Problem

NuGet product used: Visual Studio

Product version: 16.10.0

Worked before? If so, with which NuGet version: Works with nuget.exe 5.9.1.11

Repro steps and/or sample project

When I restore my solution an Exception is written in the Output Window under "Package Manager".

I have a hard time pinning down which project triggers this error. Most projects mentioned in the log are SDK-Style with PackageReference, in this pattern:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <RuntimeIdentifiers>win</RuntimeIdentifiers>
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
    <DisableImplicitAssetTargetFallback>true</DisableImplicitAssetTargetFallback>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

Some projects are additionally build for netstandard2.0 via the TargetFrameworks property.

Verbose Logs

Sorry, I do not know how to increase the Nuget verbosity in Visual Studio. When I try to restore with nuget.exe, no error occurs.

Generating MSBuild file C:\...\Project1.csproj.nuget.g.props.
Restoring packages for .NETFramework,Version=v4.7.2...
Resolving conflicts for .NETFramework,Version=v4.7.2...
Scanning packages for runtime.json files...
Restoring packages for .NETFramework,Version=v4.7.2/win...
Resolving conflicts for .NETFramework,Version=v4.7.2/win...
Writing assets file to disk. Path: C:\...\Project2\obj\project.assets.json
Writing cache file to disk. Path: C:\...\Project3\obj\project.nuget.cache
Generating MSBuild file C:\...\Project1.csproj.nuget.g.targets.
Error occurred while restoring NuGet packages: System.Exception: Restore metadata is mising the required target frameworks list. Please file a bug with repro steps on NuGet/Home if seen.
   at NuGet.ProjectModel.PackagesLockFileUtilities.IsLockFileValid(DependencyGraphSpec dgSpec, PackagesLockFile nuGetLockFile)
   at NuGet.Commands.RestoreCommand.<EvaluatePackagesLockFileAsync>d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.Commands.RestoreCommand.<ExecuteAsync>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<ExecuteAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<ExecuteAndCommitAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<CompleteTaskAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<RunAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<RunAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.DependencyGraphRestoreUtility.<RestoreAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.SolutionRestoreManager.SolutionRestoreJob.<>c__DisplayClass24_0.<<RestorePackageSpecProjectsAsync>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.SolutionRestoreManager.RestoreOperationLogger.<RunWithProgressAsync>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.SolutionRestoreManager.SolutionRestoreJob.<RestorePackageSpecProjectsAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.SolutionRestoreManager.SolutionRestoreJob.<RestoreAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.SolutionRestoreManager.SolutionRestoreJob.<RestoreAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.SolutionRestoreManager.SolutionRestoreJob.<ExecuteAsync>d__21.MoveNext()
@ps-weber ps-weber changed the title Exceptions while restoring: Restore metadata is mising the required target frameworks list Exception while restoring: "Restore metadata is mising the required target frameworks list" Jun 7, 2021
@nkolev92
Copy link
Member

nkolev92 commented Jun 7, 2021

Seems like a regression from NuGet/NuGet.Client@066a00c.

cc @kartheekp-ms.

@ps-weber
Would you be willing to try out a custom build of nuget.exe that will tell us what project is failing so we can better investigate the bug?

@nkolev92 nkolev92 added RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug Priority:2 Issues for the current backlog. Area:RestoreRepeatableBuild The lock file features Functionality:Restore labels Jun 7, 2021
@ps-weber
Copy link
Author

ps-weber commented Jun 8, 2021

@nkolev92 Sure, I'd be happy to give it a try.

@nkolev92
Copy link
Member

nkolev92 commented Jun 8, 2021

NuGet.zip

Thanks!

This was built locally, you might need to unblock it. If that doesn't work, I can try to get a proper build.

Alternatively, here's the branch for the build I created: https://github.com/NuGet/NuGet.Client/tree/dev-nkolev92-addUniqueNameToException

@nkolev92 nkolev92 added the WaitingForCustomer Applied when a NuGet triage person needs more info from the OP label Jun 8, 2021
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Jun 8, 2021

@ps-weber - In addition to what Nikolche mentioned above, please refer to https://docs.microsoft.com/en-us/visualstudio/ide/how-to-view-save-and-configure-build-log-files?view=vs-2019#to-change-the-amount-of-information-included-in-the-build-log to increase MSBuild log verbosity in Visual Studio. Hopefully at detailed verbosity we can figure out which project is triggering this error during solution restore.

image

@ps-weber
Copy link
Author

ps-weber commented Jun 9, 2021

@kartheekp-ms Increasing the msbuild verbosity only prints the stacktrace, which I have posted above.

@nkolev92 I tried your version of nuget.exe, and the restore works fine. I can only reproduce the issue inside Visual Studio (Version 16.10.1).

Through some trial and error I was able to find the affected projects and create a sample project with the issue.
vs-bug-repro.zip
If I restore the project, I get the error "Restore metadata is mising the required target frameworks list. Please file a bug with repro steps on NuGet/Home if seen". I can reliably reproduce this error by cleaning the solution first.

Thank your for your help so far.

@nkolev92
Copy link
Member

@nkolev92 nkolev92 added Triage:NeedsTriageDiscussion and removed Functionality:Restore Priority:2 Issues for the current backlog. WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Jun 10, 2021
@aortiz-msft aortiz-msft added the Priority:1 High priority issues that must be resolved in the current sprint. label Jun 10, 2021
@aortiz-msft aortiz-msft added this to the Sprint 2021-06 milestone Jun 10, 2021
@davisnw
Copy link

davisnw commented Jun 21, 2021

Started getting this error after updating to Visual Studio 16.10.2.

Fails from within Visual Studio, succeeds from msbuild.

I haven't yet been able to isolate a minimal repo, but I had a co-worker run the same steps from 16.9.0 and he did not see the error. This is a solution that has both packages.config and <PackageReference> projects - but even just building one of the <PackageReference> project individually from VS 16.10.2 results in the error - so not sure that's actually relevant.

There are also some package downgrade warnings, but I doubt that's relevant to this issue.


From Visual Studio 2019 16.9.0

  • Close all open instances of Visual Studio
  • Open Developer Command Prompt for Visual Studio 2019
> git pull

> msbuild -version
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET Framework
...
16.9.0.11203

> powershell Stop-Process -Name "VBCSCompiler" -ErrorAction SilentlyContinue

> git clean -fdx && git submodule foreach --recursive git clean -fdx
  • Open the solution in Visual Studio 2019 16.9.0 and build the solution
    • Output Window shows:
    ...
    NU1605: Detected package downgrade: EntityFramework 6.2.0 to 6.0.0
    ...
    ==========   Rebuild All: 7 Succeeded, 0 failed, 0 skipped ==========
    

From 16.10.2

  • Close all open instances of Visual Studio
  • Open Developer Command Prompt for Visual Studio 2019
> git pull

> msbuild -version
Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework
...
16.10.2.30804

> powershell Stop-Process -Name "VBCSCompiler" -ErrorAction SilentlyContinue

> git clean -fdx && git submodule foreach --recursive git clean -fdx
  • Open the solution in Visual Studio 2019 16.10.2 and build the solution
    • Output Window shows:
      Build started...
      NuGet package restore failed.  Please see Error List window for detailed warnings and errors.
      Error occurred while restoring NuGet packages: Restore metadata is mising the required target frameworks list.  Please file a bug with repro steps on NuGet/Home if seen.
      ...
      ==========  Build: 3 succeeded, 4 failed, 0 up-to-date, 0 skipped ==========
      

However:

  • Close all open instances of Visual Studio
  • Open Developer Command Prompt for Visual Studio 2019
> msbuild -version
Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework
...
16.10.2.30804

> powershell Stop-Process -Name "VBCSCompiler" -ErrorAction SilentlyContinue

> git clean -fdx && git submodule foreach --recursive git clean -fdx

> msbuild TheSolution.sln -p:RestorePackagesConfig=true -t:restore;build
...
...warning NU1605: Detected package downgrade: EntityFramework 6.2.0 to 6.0.0
...
Build succeeded.
...
21 Warning(s)
0 Error(s)

@nkolev92
Copy link
Member

Thank you all for filing these issues!

Thanks to all your detailed feedback, I was able to easily diagnose the issue and I am working on a fix in https://github.com/NuGet/NuGet.Client/tree/dev-nkolev92-fixPRtoPClockFile.

@nkolev92
Copy link
Member

PR out: NuGet/NuGet.Client#4127

Patch changes for 5.11 also running tests: https://github.com/NuGet/NuGet.Client/tree/dev-nkolev92-511xPRtoPCLockFile

@nkolev92 nkolev92 added Category:Quality Week Issues that should be considered for quality week and removed Triage:NeedsTriageDiscussion labels Jun 28, 2021
@nkolev92 nkolev92 reopened this Jul 1, 2021
@nkolev92
Copy link
Member

nkolev92 commented Jul 1, 2021

Re-opening to consider patching.
Moving to the triage.

@nkolev92 nkolev92 removed the Category:Quality Week Issues that should be considered for quality week label Jul 6, 2021
@zkat
Copy link
Contributor

zkat commented Jul 15, 2021

Closing this one. @nkolev92 do you mind creating a new issue to track the backporting?

@zkat zkat closed this as completed Jul 15, 2021
@davisnw
Copy link

davisnw commented Jul 19, 2021

Where can we track when this has been incorporated into an official Visual Studio release?

@nkolev92
Copy link
Member

nkolev92 commented Jul 19, 2021

As of now, the fix will be available in 17.0 preview 3.

@davisnw
Copy link

davisnw commented Jul 19, 2021

17.0 preview 3 looks like Visual Studio 2022.

Will this fix be backported to Visual Studio 2019 any time soon?

(I see in the discussion a link regarding backporting - however, that appears to be accessible to Microsoft employees only).

@s-tarasov
Copy link

Any updates?

@davisnw
Copy link

davisnw commented Aug 7, 2021

Vote for https://developercommunity.visualstudio.com/t/1497113 to try to get visibility for incorporating into Visual Studio 2019.

@davisnw
Copy link

davisnw commented Nov 6, 2021

The issue appears to be resolved in Visual Studio 2019 16.11.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreRepeatableBuild The lock file features Priority:1 High priority issues that must be resolved in the current sprint. RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Triage:NeedsTriageDiscussion Type:Bug
Projects
None yet
8 participants