Skip to content

Don't truncate the NuGet pre-release tag onto a trailing dot - #331

Merged
matt-richardson merged 1 commit into
mainfrom
mattr/valid-prerelease-tags
Jul 31, 2026
Merged

Don't truncate the NuGet pre-release tag onto a trailing dot#331
matt-richardson merged 1 commit into
mainfrom
mattr/valid-prerelease-tags

Conversation

@matt-richardson

@matt-richardson matt-richardson commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

DPT-3106

Why

NuGetVersion truncates the branch-derived pre-release tag to 20 characters. The cut is unaware of SemVer identifier boundaries, so when it lands on a . the emitted version ends with an empty identifier and is not a valid version string.

This broke Slipway#2356 — branch renovate/microsoft.aspnetcore.mvc.newtonsoftjson-10.x yields -renovate-microsoft., exactly 20 characters, and the build fails with error NETSDK1018: Invalid NuGet version string. Slipway#2360 works around it in that repo's workflow; the invalid string originates here, so every consumer is exposed. Once this ships, that PR can drop the workaround and keep only its branchNameStrict change.

Notes

All 20 characters are still used where they are valid, so every currently-valid output is unchanged — including cuts that land mid-identifier, and cuts that leave a trailing hyphen (a hyphen is a legal identifier character; only the dot breaks).

Two other ways to emit an invalid version turned up while verifying this, both deliberately left alone. A numeric pre-release identifier with a leading zero is invalid, so branch mattr/fix.0123 produces a version the SDK rejects, in FullSemVer as well as NuGetVersion; truncation can also create the case by cutting 0123abc down to 012. Fixing either means rewriting the user's digits so the version no longer matches the branch it came from, which isn't worth it — a branch name that trips this needs renaming.

Verified against the real SDK: dotnet build -p:Version=1.1.47-renovate-microsoft. fails, -renovate-microsoft succeeds.

🤖 Generated with Claude Code

A pre-release tag ending in a dot has an empty final identifier, which
is not a valid version string.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@matt-richardson
matt-richardson requested a review from a team as a code owner July 31, 2026 04:52
@matt-richardson
matt-richardson merged commit 9490d87 into main Jul 31, 2026
4 checks passed
@matt-richardson
matt-richardson deleted the mattr/valid-prerelease-tags branch July 31, 2026 05:33
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.

2 participants