-
Notifications
You must be signed in to change notification settings - Fork 258
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
RestorePackagesWithLockFile: Nuget.exe generates different lock file than Visual Studio #12683
Comments
Bug is somewhere here: https://github.com/NuGet/NuGet.Client/blob/69ef354945cf5ec2029b35be024e7b34ec9becbf/src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/MSBuildRestoreUtility.cs#L520-L568. Good news is static graph restore works. Hey @codereader, can you try using Nowadays it supports packages.config, so as long as you use that if you have packages.config https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#restoring-packagereference-and-packagesconfig-projects-with-msbuild it'll be equivalent. What does work is static graph evaluation restore. Can you try that out and let us know how it goes. |
Thanks for taking the time to look into this.
But I can confirm that using What's the deal with Static Graph Evaluation? I assume it's the only option I have, is it reliable to use at this point? The Microsoft article states it's "experimental" but the info appears to be from years ago. The issue page (#9803) advises me to check for differences by running restore with and without static graph evaluation, but obviously I can't compare these two when one of them is not finishing successfully. Thanks so far for pointing me to a workaround, I'll try this in production. |
Update: Static Graph Evaluation is failing on the bigger, productive solution file:
|
Restore with static graph evaluation is a feature that is really helpful for large repositories that have 50+ projects that would take a long time to parse an evaluate. It's unfortunate that you're hitting that different issue. Not really sure what the problem is there. Do you mind creating a different issue for that? |
NuGet Product Used
NuGet.exe, Visual Studio
Product Version
NuGet.exe 6.6.1 + Visual Studio 2022 17.6.3 (NuGet 6.6.0 built-in)
Worked before?
Not that I know of
Impact
I'm unable to use this version
Repro Steps & Context
I have a solution containing mixed C#/C++ projects. The attached repro solution contains one C#/.NET 6 Project referencing a C++/CLR project, which in turn references a plain C++ project. The C# project references a single NuGet Package
System.Memory
, and is using the Central Package Management feature (not sure if this is relevant). I'm aiming to achieve reproducible nuget restores, therefore I enabled the RestorePackagesWithLockFile setting.Problem is, the
packages.lock.json
file is different depending on whether it's generated by nuget.exe or Visual Studio. When enabling the RestoreLockedMode setting, either one, VS or nuget.exe, will run into trouble when hitting a lock file generated by the other.The attached demo solution contains the
packages.lock.json
files as generated by VS and has<RestoreLockedMode>true</RestoreLockedMode>
activated in theDirectory.Packages.props
file. When trying to run anuget restore
using the CLI (v6.6.1) it will report that the dependencies of the C++ CLR project have changed:It boils down to Studio adding the "project" type reference to
common
to the lock file, whereas the CLI doesn't recognize the ProjectReference:I can twist it around and have
nuget.exe
generate the lock file, but then Visual Studio will complain about the lock file (sometimes with a more cryptic message about missing frameworks). Either way, one cannot deal with the lock file generated by the other toolchain.Is there anything I can do to resolve this issue? I need the nuget client to produce the same result as the one in studio, since a
nuget.exe restore
is one of the first steps happening on the build agent, and if it can't deal with the lock files produced by the developer's VS, this prevents us from using the locked restore mode.Of course, the actual productive solution is of course far more complex, this is just a boiled-down example.
LockedRestore.zip
Verbose Logs
The text was updated successfully, but these errors were encountered: