-
Notifications
You must be signed in to change notification settings - Fork 255
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
"dotnet restore --locked-mode" does not respect global.json #13344
Comments
NuGet itself does not enforce the .NET SDK used by |
@jeffkl I think a related but relevant question here would be 'how should lock files and users of them think about packages that are implicitly provided by the SDK'? I know for CPM implicit packages are ignored, but I'm not sure that would make as much sense for lock file users. |
I have already tried to create this issue in "https://github.com/dotnet/sdk/issues/": But here it was also closed and asked me to create it here :/ |
@baronfel I don't fully agree that lock files don't make sense for implicit packages. I'm don't fully disagree either. Lock files have (at least) two purposes, and there's room for different opinions about how much different things matter. There isn't one objective "this is obviously the correct way". One use of lock files is to pin versions. It's completely understandable that some people would want implicit packages to be absent from the lock file. However, If the implicit package has dependencies, should the dependencies be listed in the lock file? If a package is a transitive dependency of both an implicit package, and a project's explicit PackageReference, but then updating to a newer .NET SDK causes the transitive package to choose a higher version, should If an implicit package doesn't have any dependencies, the product team can switch to The second use of lock files is to validate content hashes, to increase supply chain security. In this case, omitting implicit packages is a risk because it loses the protection. I mean, the same is true for Honestly, I'm also wondering why this specific package Microsoft.NET.ILLink.Tasks, is a package, and isn't just inserted into the SDK directly. |
NuGet Product Used
dotnet.exe
Product Version
.NET Core SDK v8.0.202
Worked before?
I do not think so
Impact
It bothers me. A fix would be nice
Repro Steps & Context
Hi,
I have a project using:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
and
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
I get an auto-referenced package added to the "packages.lock.json" file:
I do not have a direct reference to "Microsoft.NET.ILLink.Tasks". It is also marked with "(A)" when doing a "dotnet list .\Client.csproj package":
I have a global.json file that looks like this:
When running "dotnet restore --force-evaluate" it respects the SDK version in global.json and updates the packages.lock.json file to use v8.0.2 of Microsoft.NET.ILLink.Tasks:
The Microsoft-hosted agents have v8.0.202 installed and when running "dotnet restore --locked-mode" it does not respect global.json and fails:
"error NU1004: The package reference Microsoft.NET.Sdk.WebAssembly.Pack version has changed from [8.0.3, ) to [8.0.2, ).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."
Best Regards,
Anders Havn
Expected Behavior
"dotnet restore --locked-mode" also respects the .NET SDK version in global.json.
Verbose Logs
No response
The text was updated successfully, but these errors were encountered: