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

MSBuild SDK resolver tries to validate SHA for a SDK package which fails restore when using packages.lock.json #7599

Closed
bergbria opened this issue Dec 7, 2018 · 1 comment · Fixed by NuGet/NuGet.Client#2573

Comments

@bergbria
Copy link

bergbria commented Dec 7, 2018

Details about Problem

dotnet.exe --version: 2.2.100

Suppose I have a project P that uses nuget sdk N and N has never been installed on the machine.

If P does not contain a packages.lock.json file, dotnet restore --use-lock-file will succeed.
If P does have a lock file, dotnet restore --use-lock-file will print errors the first time, then succeed on subsequent runs

Detailed repro steps so we can see the same problem

  1. Unzip lockFile_spuriousError_repro.zip somewhere on your machine.

  2. Run repro.bat

...

After debugging through the code a bit, the issue comes to a head in ValidatePackagesSha512(PackagesLockFile lockFile, LockFile assetsFile). The method effectively checks that all the hashes in the in-memory assets.json object match those in the lock file. This normally works fine since the sdk packages aren't actually written to either file. However, in the degenerate case, the SDK package appears in assetsFile for some reason (though the sdk package is never included in the generated file). In this case, the error is produced since lockFile has no corresponding hash.

@jainaashish jainaashish self-assigned this Dec 7, 2018
@jainaashish jainaashish added this to the 4.9.x milestone Dec 7, 2018
@jainaashish
Copy link
Contributor

the issue is it tries to validate SHA during SDK resolver because SDK resolver also internally calls restore API.

@jainaashish jainaashish changed the title Packages.lock.json causes spurious 'dotnet restore' errors when using a nuget-based MSBuild project sdk MSBuild SDK resolver tries to validate SHA for a SDK package which fails restore Dec 7, 2018
@jainaashish jainaashish changed the title MSBuild SDK resolver tries to validate SHA for a SDK package which fails restore MSBuild SDK resolver tries to validate SHA for a SDK package which fails restore when using packages.lock.json Dec 7, 2018
@jainaashish jainaashish changed the title MSBuild SDK resolver tries to validate SHA for a SDK package which fails restore when using packages.lock.json MSBuild SDK resolver tries to validate SHA for a SDK package which fails restore when using packages.lock.json Dec 7, 2018
@rrelyea rrelyea modified the milestones: 4.9.x, 4.9.3 Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment