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

Restoring two projects in parallel that use a NuGet provided SDK may race #14064

Closed
Youssef1313 opened this issue Jan 23, 2025 · 1 comment
Closed

Comments

@Youssef1313
Copy link

NuGet Product Used

dotnet.exe

Product Version

10.0.100-alpha.1.24573.1

Worked before?

Unknown, but unlikely that it worked before

Impact

It's more difficult to complete my work

Repro Steps & Context

In microsoft/testfx, we are producing an MSTest.Sdk, and we have integration tests for it.

It seems that when two tests are restoring in parallel, we may end up with the following

/mnt/vss/_work/1/s/artifacts/tmp/Debug/testsuite/dTeXr/VerifyMSTestAnalysisModeForDifferentAnalyzers/VerifyMSTestAnalysisModeForDifferentAnalyzers.csproj Could not resolve SDK "MSTest.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
  SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
  Failed to resolve SDK 'MSTest.Sdk/3.8.0-ci'. Package restore was successful but a package with the ID of "MSTest.Sdk" was not installed.

What we do is simply we crate projects on disk, and we run dotnet build on them.

What I think could be happening is:

  1. Two dotnet build invocations for two different projects that use MSTest.Sdk are done in parallel
  2. First invocation finds the nupkg file (it's found locally, not from an online feed in our case). It starts extracting the nupkg
  3. The second invocation thinks that the restore is successful while the extraction is still in progress, and we reach this code path (which is thought to be unreachable). https://github.com/NuGet/NuGet.Client/blob/313eecd3af442ee2eeed2e6decf310858934ab21/src/NuGet.Core/Microsoft.Build.NuGetSdkResolver/NuGetSdkResolver.cs#L237-L239

Two binlogs for the two dotnet build invocations that went in parallel (and sorry, one of them is run with Italian culture as it's a test for localization)

binlogs.zip

Verbose Logs

@jeffkl
Copy link
Contributor

jeffkl commented Jan 23, 2025

Duplicate of #11443

This hasn't been very high priority since the problem usually manifests when users are doing very custom things. Please upvote the other issue though as I'm hoping to have time to re-write the NuGet-based MSBuild project SDK resolver.

@jeffkl jeffkl closed this as completed Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants