Don't truncate the NuGet pre-release tag onto a trailing dot - #331
Merged
Conversation
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>
cailyoung
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DPT-3106
Why
NuGetVersiontruncates 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.xyields-renovate-microsoft., exactly 20 characters, and the build fails witherror 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 itsbranchNameStrictchange.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.0123produces a version the SDK rejects, inFullSemVeras well asNuGetVersion; truncation can also create the case by cutting0123abcdown to012. 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-microsoftsucceeds.🤖 Generated with Claude Code