Skip to content

[release/10.0.1xx] [build] Fix NuGet migration race condition workaround - #25996

Merged
rolfbjarne merged 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-25960-release/10.0.1xx-2026-07-09
Jul 10, 2026
Merged

[release/10.0.1xx] [build] Fix NuGet migration race condition workaround#25996
rolfbjarne merged 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-25960-release/10.0.1xx-2026-07-09

Conversation

@rolfbjarne

@rolfbjarne rolfbjarne commented Jul 9, 2026

Copy link
Copy Markdown
Member

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

Backport of #25960.
Backport of #25849.

…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>
Copilot AI review requested due to automatic review settings July 9, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Migration1 is safe in the CI scenario.

Comment thread builds/Makefile
Comment on lines +53 to +58
$(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
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #ed36e85] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: ed36e8560b0713b5e9d9155a6123e983862b3288 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: ed36e8560b0713b5e9d9155a6123e983862b3288 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #ed36e85] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: ed36e8560b0713b5e9d9155a6123e983862b3288 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #ed36e85] Build passed (Build packages) ✅

Pipeline on Agent
Hash: ed36e8560b0713b5e9d9155a6123e983862b3288 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne enabled auto-merge (squash) July 9, 2026 09:57
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 14 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 16 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 16 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 14 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: ed36e8560b0713b5e9d9155a6123e983862b3288 [PR build]

@rolfbjarne
rolfbjarne merged commit 7076227 into release/10.0.1xx Jul 10, 2026
49 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/backport-pr-25960-release/10.0.1xx-2026-07-09 branch July 10, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants