Skip to content

[release/11.0.1xx-preview6] [build] Fix NuGet migration race condition workaround (#25849) - #25960

Merged
dalexsoto merged 1 commit into
release/11.0.1xx-preview6from
dev/rolf/backport-pr-25849-release/11.0.1xx-preview6-2026-07-07
Jul 7, 2026
Merged

[release/11.0.1xx-preview6] [build] Fix NuGet migration race condition workaround (#25849)#25960
dalexsoto merged 1 commit into
release/11.0.1xx-preview6from
dev/rolf/backport-pr-25849-release/11.0.1xx-preview6-2026-07-07

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


…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 7, 2026 15:33

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 migration race (dotnet/runtime#91987) in the release/11.0.1xx-preview6 branch by creating NuGet’s migration marker file directly after installing the SDK.

Changes:

  • Adds a CI-only (ACES-gated) step in the .NET SDK download/install rule to create ~/.local/share/NuGet/Migrations/1, avoiding NuGet’s migration mutex contention.

Comment thread builds/Makefile
@dalexsoto
dalexsoto merged commit 7f0236e into release/11.0.1xx-preview6 Jul 7, 2026
10 of 18 checks passed
@dalexsoto
dalexsoto deleted the dev/rolf/backport-pr-25849-release/11.0.1xx-preview6-2026-07-07 branch July 7, 2026 15:37
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [PR Build #$(fix_c] Build failed (Build packages) 🔥

Build failed for the job 'Build packages' (with job status 'Failed')

Pipeline on Agent
Hash: $(fix_commit.GIT_HASH) [PR build]

rolfbjarne added a commit that referenced this pull request Jul 10, 2026
…und (#25996)

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.

---------

Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants