Skip to content

Fix NuGet VMR build number wrapping around on October 1st - #9985

Merged
ViktorHofer merged 1 commit into
mainfrom
viktorhofer/fix-nuget-buildnumber-wrap
Oct 6, 2026
Merged

ViktorHofer merged 1 commit into
mainfrom
viktorhofer/fix-nuget-buildnumber-wrap

Conversation

@ViktorHofer

Copy link
Copy Markdown
Member

Fixes the NU1109 package downgrade errors breaking every leg of the official dotnet-unified-build since October 1st, e.g. https://dev.azure.com/dnceng/internal/_build/results?buildId=3096775:

src/sdk/src/Layout/redist/tools/tool_projectdata.csproj : error NU1109: Detected package downgrade: NuGet.Versioning from 8.0.0-rc.48205 to centrally defined 8.0.0-rc.731.
  tool_projectdata -> Microsoft.NET.ProjectData.Tasks 5.13.0-1.26505.131 -> NuGet.Versioning (>= 8.0.0-rc.48205)
  tool_projectdata -> NuGet.Versioning (>= 8.0.0-rc.731)

Root cause

repo-projects/nuget-client.proj computes NuGet's BuildNumber as _PatchNumber % 50000 (nuget-client's config.props then adds 100). Arcade's _PatchNumber is ((yy - 19) * 1000 + mm * 50 + dd) * 100 + r, so the result wraps from ~48xxx to ~1xx on October 1st. Unlike Arcade (which carries PatchNumber / 50000 into the assembly patch field), NuGet has no other field to absorb the overflow.

Roslyn's Microsoft.NET.ProjectData.Tasks references NuGet.Versioning pinned to 8.0.0-rc.48205 (8.0.0-rc.48202 for source-only builds) from a September VMR build. Roslyn doesn't build after nuget-client in the VMR, and can't in source-only builds (msbuild → roslyn, nuget-client → msbuild). The live NuGet version is now 8.0.0-rc.731, which is lower than roslyn's pin, so the sdk fails restore.

Fix

Use modulo 100000 instead, which yields (mm * 50 + dd) * 100 + r:

  • Identical values for January to September, so nothing changes for already-produced versions.
  • Monotonically increasing until the end of the calendar year. Today's build becomes 8.0.0-rc.50731, which is above 48205.
  • The max is ~63399 (Dec 31, incl. the +100), so it stays within the UInt16 assembly version limit and below nuget-client's 65534 dev sentinel.

Verified with MSBuild evaluation of Arcade's _PatchNumber expression plus nuget-client's +100 offset:

OfficialBuildId old new
20260930.105 rc.48205 rc.48205
20261001.101 rc.301 rc.50301
20261005.131 rc.731 rc.50731
20261231.199 rc.13399 rc.63399
20270101.101 rc.5301 rc.5301

Known limitation

The value still wraps at the year boundary (Jan 1st). The previous formula also wrapped there, and this change doesn't fix that. Any NuGet versions pinned in other repos from late-December builds would hit the same downgrade on Jan 1st unless NuGet's major/minor version changes or the scheme is revisited.

nuget-client's VMR BuildNumber was computed as PatchNumber % 50000. Since
PatchNumber is ((yy - 19) * 1000 + mm * 50 + dd) * 100 + r, the value wraps
from ~48xxx to ~1xx on October 1st. Live NuGet packages (e.g. 8.0.0-rc.731)
became lower than versions pinned by repos that don't build after
nuget-client (roslyn's NuGet.Versioning 8.0.0-rc.48205), failing the sdk
build with NU1109 package downgrade errors in tool_projectdata.csproj.

Use modulo 100000 instead which yields (mm * 50 + dd) * 100 + r: identical
values for January - September, monotonically increasing until the end of
the calendar year, and within the UInt16 assembly version limit.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1a609b5e-5df1-40ff-8cd7-cbe2e0e3ff01
Copilot AI balanced review requested due to automatic review settings October 6, 2026 08:49
@ViktorHofer
ViktorHofer requested review from a team as code owners October 6, 2026 08:49
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Copilot review overview

🟢 Approval recommended

The calculation is correct, preserves prior versions, and resolves the documented October wraparound.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents October NuGet version wraparound from causing NU1109 downgrades in VMR builds.

Changes:

  • Expands _PatchNumber modulus from 50,000 to 100,000.
  • Documents the versioning rationale and UInt16 constraint.
File Description
repo-projects/​nuget-client.proj Corrects NuGet build-number calculation.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@ViktorHofer
ViktorHofer enabled auto-merge (squash) October 6, 2026 11:05
@ViktorHofer
ViktorHofer merged commit 9ca8cda into main Oct 6, 2026
12 checks passed
@ViktorHofer
ViktorHofer deleted the viktorhofer/fix-nuget-buildnumber-wrap branch October 6, 2026 11:42
@mmitche

mmitche commented Oct 13, 2026

Copy link
Copy Markdown
Member

/backport to release/11.0.1xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

AlesProkop added a commit that referenced this pull request Nov 16, 2026
nuget-client got no BuildNumber in VMR builds because the property was
evaluated before _PatchNumber is defined, so all NuGet packages were
versioned rc.65534 and promotion failed with "already exists ... with
different content" on dotnet-tools. This also takes the modulo 100000
change so the number doesn't wrap on October 1st.

Co-authored-by: Copilot App <[email protected]>
AlesProkop added a commit that referenced this pull request Nov 16, 2026
nuget-client got no BuildNumber in VMR builds because the property was
evaluated before _PatchNumber is defined, so all NuGet packages were
versioned rc.65534 and promotion failed with "already exists ... with
different content" on dotnet-tools. This also takes the modulo 100000
change so the number doesn't wrap on October 1st.

Co-authored-by: Copilot App <[email protected]>
akoeplinger pushed a commit that referenced this pull request Nov 16, 2026
akoeplinger pushed a commit that referenced this pull request Nov 16, 2026
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