-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
dnx is a batch file created and added to the user's %PATH% when installing .NET 10 SDK or greater. The batch file essentially just forwards all command-line arguments to dotnet tool execute. However, users can run the command in a directory that happens to have a global.json which points to an older version. This leads to dnx forwarding the arguments to an older SDK which may or may not have the dotnet tool execute command. In that case, the user gets head scratching error telling them that the execute command doesn't exist, which is confusing because they ran dnx.
D:\>dotnet tool execute NuGet.Mcp.Server --yes
Unrecognized command or argument 'execute'.
Unrecognized command or argument 'NuGet.Mcp.Server'.
Unrecognized command or argument '--yes'.
Description:
Install or work with tools that extend the .NET experience.
Usage:
dotnet tool [command] [options]
Options:
-?, -h, --help Show command line help.
Commands:
install <PACKAGE_ID> Install global or local tool. Local tools are added to manifest and restored.
uninstall <PACKAGE_ID> Uninstall a global tool or local tool.
update <PACKAGE_ID> Update a global or local tool.
list <PACKAGE_ID> List tools installed globally or locally.
run <COMMAND_NAME> <toolArguments> Run a local tool. Note that this command cannot be used to run a global tool.
search <SEARCH_TERM> Search dotnet tools in nuget.org
restore Restore tools defined in the local tool manifest.
There is likely nothing that can be done since the muxer is doing things correctly by respecting global.json and selecting the older version of the SDK. Ideally, the dnx command could somehow indicate that it must run against .NET 10, but there is no mechanism for that at the moment.
#49796 hopes to address this by shipping dnx as a standalone executable that doesn't need the SDK at all and would not suffer from this problem.
To Reproduce
- Create a
global.jsonpointing to an older SDK than 10
{
"sdk": {
"version": "9.0.1xx",
"rollForward": "latestMinor"
}
}- Run
dnx SomeTool
Exceptions (if any)
Further technical details
details of dotnet --info