[release/10.0.1xx] [build] Fix NuGet migration race condition workaround - #25996
Conversation
…n workaround (#25849) The previous workaround (from #25797) ran `dotnet --info` after downloading the SDK to trigger NuGet's first-time migration and avoid the race condition described in dotnet/runtime#91987. However, `dotnet --info` doesn't reliably trigger the migration code path -- the migration (`MigrationRunner.Run()`) is invoked from: 1. `DotnetFirstTimeUseConfigurer` in the dotnet CLI (first-use flow, which `--info` may bypass) 2. `NuGetSdkResolver` during MSBuild SDK resolution (only during build/restore) This PR replaces the `dotnet --info` call with directly creating the NuGet migration marker file (`~/.local/share/NuGet/Migrations/1`). When this file exists, NuGet's `MigrationRunner` returns immediately without acquiring the "NuGet-Migrations" mutex -- completely eliminating the race condition. The migration itself (`Migration1`) only cleans up old NuGet directories, which is a no-op on a fresh SDK installation, so skipping it is safe. Ref: dotnet/runtime#91987 Ref: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Common/Migrations/MigrationRunner.cs --- 🤖 Pull request created by Copilot --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the build-time workaround for the NuGet first-time migrations race (dotnet/runtime#91987) by avoiding dotnet --info and instead creating NuGet’s migration marker file, which prevents NuGet from attempting to acquire the problematic NuGet-Migrations mutex during subsequent restore/build operations in CI.
Changes:
- Adds a CI-only step after SDK installation to create
~/.local/share/NuGet/Migrations/1. - Documents why skipping
Migration1is safe in the CI scenario.
| $(Q) if test -n "$$ACES"; then \ | ||
| NUGET_MIGRATIONS_DIR="$$HOME/.local/share/NuGet/Migrations"; \ | ||
| mkdir -p "$$NUGET_MIGRATIONS_DIR"; \ | ||
| touch "$$NUGET_MIGRATIONS_DIR/1"; \ | ||
| echo "Created NuGet migrations marker file to avoid race condition (dotnet/runtime#91987)"; \ | ||
| fi |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #ed36e85] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #ed36e85] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ [PR Build #ed36e85] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #ed36e85] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 167 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
The previous workaround (from #25797) ran
dotnet --infoafter downloading the SDK to trigger NuGet's first-time migration and avoid the race condition described in dotnet/runtime#91987. However,dotnet --infodoesn't reliably trigger the migration code path -- the migration (MigrationRunner.Run()) is invoked from:DotnetFirstTimeUseConfigurerin the dotnet CLI (first-use flow, which--infomay bypass)NuGetSdkResolverduring MSBuild SDK resolution (only during build/restore)This PR replaces the
dotnet --infocall with directly creating the NuGet migration marker file (~/.local/share/NuGet/Migrations/1). When this file exists, NuGet'sMigrationRunnerreturns immediately without acquiring the "NuGet-Migrations" mutex -- completely eliminating the race condition.The migration itself (
Migration1) only cleans up old NuGet directories, which is a no-op on a fresh SDK installation, so skipping it is safe.Ref: dotnet/runtime#91987
Ref:
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Common/Migrations/MigrationRunner.cs
🤖 Pull request created by Copilot
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Backport of #25960.
Backport of #25849.