Repository navigation
Simplify .NET SDK version handling logic - #764
Merged
Merged
Conversation
Andy Gerlicher (AndyGerlicher)
approved these changes
Nov 16, 2026
Andy Gerlicher (AndyGerlicher)
merged commit Nov 16, 2026
b31b274
into
microsoft:main
3 checks passed
Collaborator
|
Andy Gerlicher (@AndyGerlicher) this simplification will work at run time, but not if there is no assets. The SlnGen tool is a shim that runs the correct EXE for the configured version of .NET based on global.json. So if .NET 12 is selected, it will try to run the net12.0 slngen. But if the package doesn't contain it, then it will fail in a strange way, which is why the code was written to just log an error that SlnGen doesn't currently support that .NET. So I think there should still be logic in SlnGen that detects what versions it supports. |
Andy Gerlicher (AndyGerlicher)
added a commit
that referenced
this pull request
Nov 16, 2026
Move the .NET SDK to SlnGen target framework selection into a shared SlnGenFramework helper so it can be unit tested. The tests cover SDK 10/11 selecting their matching build regardless of the runtime running the tests (which fails with the Environment.Version approach from #764), a newer SDK without a matching build being reported as unsupported, a newer SDK being picked up automatically once its build is in the package, and older or unparseable SDK versions. Also clarify the "not supported" error: the SDK may be selected without a global.json, so refer to the currently configured SDK and suggest pinning a supported SDK via global.json. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5c98cb9a-2a07-496a-bfa1-68cf9e8a1498
Andy Gerlicher (AndyGerlicher)
added a commit
that referenced
this pull request
Nov 17, 2026
* Select SlnGen framework from the .NET SDK version in global.json #764 switched framework selection to the runtime version of the tool shim (Environment.Version). Because the shim uses RollForward=LatestMajor, this picks the newest installed runtime rather than the SDK selected by global.json, so a machine with a newer runtime than SlnGen ships for fails with 'SlnGen not found' even if global.json pins a supported SDK. Go back to using the SDK major version, but instead of a hard-coded list, check whether the package contains a matching slngen/netX.0 build and show the friendly 'not supported' error otherwise. Adding a new target framework to the tool project is now all that's needed to support a new SDK. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 06156545-6fe1-415f-b5ee-31214628068c * Extract SlnGen framework selection and add tests Move the .NET SDK to SlnGen target framework selection into a shared SlnGenFramework helper so it can be unit tested. The tests cover SDK 10/11 selecting their matching build regardless of the runtime running the tests (which fails with the Environment.Version approach from #764), a newer SDK without a matching build being reported as unsupported, a newer SDK being picked up automatically once its build is in the package, and older or unparseable SDK versions. Also clarify the "not supported" error: the SDK may be selected without a global.json, so refer to the currently configured SDK and suggest pinning a supported SDK via global.json. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5c98cb9a-2a07-496a-bfa1-68cf9e8a1498 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 06156545-6fe1-415f-b5ee-31214628068c Copilot-Session: 5c98cb9a-2a07-496a-bfa1-68cf9e8a1498
This was referenced Nov 17, 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.
Andy Ayers (@AndyAyersMS) it will scale better and enable net12 preview release which dotnet repos are currently using.