Skip to content

Improve global.json SDK version validation for rollForward#742

Merged
HarithaVattikuti merged 1 commit into
actions:mainfrom
priyagupta108:validate-sdk-version-rollforward
Jun 16, 2026
Merged

Improve global.json SDK version validation for rollForward#742
HarithaVattikuti merged 1 commit into
actions:mainfrom
priyagupta108:validate-sdk-version-rollforward

Conversation

@priyagupta108

Copy link
Copy Markdown
Contributor

Description:
This PR validates the sdk.version format in global.json when rollForward is specified and skips rollForward optimization for prerelease SDK versions.

Related issue:
#739
#740

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI review requested due to automatic review settings June 11, 2026 09:46
@priyagupta108 priyagupta108 requested a review from a team as a code owner June 11, 2026 09:46
@priyagupta108 priyagupta108 self-assigned this Jun 11, 2026

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

This PR hardens global.json handling in setup-dotnet by validating sdk.version when rollForward is present (to avoid parsing errors) and by preventing the action’s rollForward “optimization” from rewriting prerelease SDK versions (so prerelease pins remain exact).

Changes:

  • Add sdk.version format validation (full SDK version required) before applying rollForward optimization.
  • Skip rollForward optimization entirely for prerelease SDK versions to ensure exact prerelease installs.
  • Update documentation and e2e workflow coverage to reflect and exercise the new behavior.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/setup-dotnet.ts Adds sdk.version validation for rollForward and skips optimization for prerelease versions.
README.md Documents that prerelease SDK pins are installed exactly regardless of rollForward.
dist/setup/index.js Updates the compiled distribution output to match the TypeScript changes.
.github/workflows/e2e-tests.yml Adjusts e2e rollForward test inputs to use a full SDK version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/setup-dotnet.ts
Comment thread .github/workflows/e2e-tests.yml
@Frulfump

Frulfump commented Jun 11, 2026

Copy link
Copy Markdown

Shouldn't version be validated even if rollForward isn't specified? It has a default value even if not present.

From the docs https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#matching-rules

If a global.json file is found and it specifies an SDK version:

If no rollForward value is set, it uses patch as the default rollForward policy.

@priyagupta108

Copy link
Copy Markdown
Contributor Author

@Frulfump,
Thank you for the suggestion. However, validating sdk.version when rollForward is not specified would be a breaking change. Users with incomplete versions, such as 8.0, that previously worked would suddenly start failing.

The validation is scoped to this case because the rollForward parsing logic requires a full version to avoid cryptic errors. We are exploring broader validation for consistency with the official global.json spec in a follow-up change.

For now, this PR is focused on fixing #739 and #740.

@Frulfump

Frulfump commented Jun 15, 2026

Copy link
Copy Markdown

It could be a warning not necessarily a hard break to guide users to a valid global.json and it already has a default value so it's always there from the .NET SDKs perspective at least.

@priyagupta108

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up, @Frulfump. We really appreciate you digging into this.

Just one quick clarification on the mechanics. The patch default you're referencing lives in the .NET CLI/host, which reads global.json at runtime to select an SDK that is already installed on the machine.

setup-dotnet works at a slightly different layer. It runs before any SDK exists, and its job is to decide what to download. So when rollForward is omitted, it doesn't apply that patch default itself. It simply forwards sdk.version to the version resolver and install script, without any rollForward handling.

For that reason, the hard error in this PR is intentionally scoped to the rollForward case, where an incomplete version genuinely breaks our parsing (#739).

Hope that helps clarify the intent.

@Frulfump

Copy link
Copy Markdown

@priyagupta108 Thanks for the additional info. That makes sense!

@HarithaVattikuti HarithaVattikuti merged commit 95a3f8b into actions:main Jun 16, 2026
120 of 123 checks passed
@benmccallum

benmccallum commented Jun 26, 2026

Copy link
Copy Markdown

This broke us 😄 We were, admittedly + wrongly, doing 9.0.0 with rollForward, I guess never realising that wasn't a valid version and it starts at 9.0.100, so the regex validating the patch is non-zero caught us out whereas it previously worked. Easy enough to fix, but there might be a lot of folks affected temporarily by this and it might've warranted a major version bump - though I do get that if it's breaking your rollForward logic, it may have been required to force us all on the right path ASAP.

@Frulfump

Frulfump commented Jun 26, 2026

Copy link
Copy Markdown

There's an issues here for that if you want to follow / upvote that. #753

And here's the .NET SDK issue to turn it into an error instead of just informational dotnet/sdk#49816

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.

7 participants