Skip to content

[build] Fix NuGet migration race condition workaround#25833

Draft
rolfbjarne wants to merge 1 commit into
mainfrom
rolfbjarne-fix-nuget-migration-workaround
Draft

[build] Fix NuGet migration race condition workaround#25833
rolfbjarne wants to merge 1 commit into
mainfrom
rolfbjarne-fix-nuget-migration-workaround

Conversation

@rolfbjarne

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

The previous workaround ran 'dotnet --info' to trigger the first-time
NuGet migration, but this command doesn't reliably trigger the migration
code path. The migration is triggered by DotnetFirstTimeUseConfigurer
(first CLI use) and NuGetSdkResolver (MSBuild SDK resolution), neither
of which is invoked by 'dotnet --info'.

Instead, directly create the NuGet migration marker file
(~/.local/share/NuGet/Migrations/1). When this file exists, NuGet's
MigrationRunner.Run() skips the mutex entirely, eliminating the race
condition. The migration itself (Migration1) only cleans up old NuGet
directories, which is a no-op on a fresh SDK installation.

Ref: dotnet/runtime#91987
Ref: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Common/Migrations/MigrationRunner.cs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build #959ede6] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 959ede6a5f50ca3d77b764e0a8cf8086f30c40ab [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #959ede6] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 959ede6a5f50ca3d77b764e0a8cf8086f30c40ab [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@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: 959ede6a5f50ca3d77b764e0a8cf8086f30c40ab [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build #959ede6] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 959ede6a5f50ca3d77b764e0a8cf8086f30c40ab [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #959ede6] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

5 tests crashed, 0 tests failed, 174 tests passed.

Failures

❌ Tests on macOS Monterey (12) tests

🔥 Failed catastrophically on VSTS: test results - mac_monterey (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Ventura (13) tests

🔥 Failed catastrophically on VSTS: test results - mac_ventura (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Sonoma (14) tests

🔥 Failed catastrophically on VSTS: test results - mac_sonoma (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Sequoia (15) tests

🔥 Failed catastrophically on VSTS: test results - mac_sequoia (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

🔥 Failed catastrophically on VSTS: test results - mac_tahoe (no summary found).

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. 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 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. 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

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 959ede6a5f50ca3d77b764e0a8cf8086f30c40ab [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants