[release/10.0.3xx] Update the dnx script to use the newest SDK - #54587
Merged
JoeRobich merged 5 commits intoJun 4, 2026
Conversation
The dnx scripts worked by invoking `dotnet dnx`. This creates issues in folders where a global.json has pinned a version of the SDK which does not support the `dnx` command. We change the behavior of the scripts to use `dotnet--list-sdks` to get the list of installed SDKs. We then take the last entry, which should be the latest as the list is sorted. We then directly execute that version of the dotnet.dll. This allows the dnx script to script to work despite any global.json. Resolves #51085
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joey Robichaud <joseph.robichaud@microsoft.com>
Member
|
/tactics |
JoeRobich
approved these changes
Jun 4, 2026
This was referenced Jun 10, 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.
Backport of #54472 to release/10.0.3xx
/cc
@JoeRobichTactics
Summary
The
dnxshell/batch scripts were invokingdotnet dnx, which respects anyglobal.jsonin the working directory. Ifglobal.jsonpins an older SDK (pre-.NET 10) that doesn't support thednx/tool executecommand, users get a confusing "Unrecognized command or argument 'execute'" error. The fix changes bothdnxanddnx.cmdto usedotnet --list-sdksto find the newest installed SDK, then directly invokesdotnet exec <sdk-path>/dotnet.dll dnx, bypassingglobal.jsonentirely. This is a safe, targeted fix appropriate for servicing because it only changes the launcher scripts and does not affect SDK internals.Customer Impact
Users running
dnx(ordotnet tool execute) in a directory containing aglobal.jsonthat pins an SDK older than .NET 10 receive an unhelpful error:Unrecognized command or argument 'execute'. This affects all .NET 10 SDK users who work in repositories or directories with aglobal.jsonpointing to an older SDK version. The workaround is to rundnxfrom a directory without such aglobal.json, which is unintuitive. The issue affects .NET 10.0.3xx (this backport) and main (addressed by #54472).Regression?
No — this is not a regression introduced by a specific PR. The
dnxscript was always susceptible toglobal.jsonversion pinning since its initial introduction, because it relied on the SDK muxer which respectsglobal.json. The bug is a design limitation documented in issue #51085.Testing
main.global.jsonpinning SDK to9.0.1xxand rundnx SomeTool— before fix this fails with an unrecognized command error; after fix it correctly uses the newest installed SDK.Risk
Low. The change is confined to two small shell scripts (
dnxanddnx.cmd) with no impact on SDK internals, MSBuild targets, or C# code. The logic is simple: enumerate installed SDKs, take the last (newest) one, and invoke it directly. The only edge case is a machine with no SDK installed, which would already fail before this change. Test coverage is via CI and manual validation.