Skip to content

Add a design proposal for dotnet tool exec and dnx#334

Merged
marcpopMSFT merged 5 commits intomainfrom
marcpopMSFTtoolexecdnx
Jun 10, 2025
Merged

Add a design proposal for dotnet tool exec and dnx#334
marcpopMSFT merged 5 commits intomainfrom
marcpopMSFTtoolexecdnx

Conversation

@marcpopMSFT
Copy link
Member

This is an attempt to summarize our discussions from the WIP for dotnet tool exec and offline discussions about having a shortcut dnx:
dotnet/sdk#31103
dotnet/sdk#48443

For dnx, we need to decide if there are some flags automatically set like --ignore-failed-sources or --yes.

@yaakov-h
Copy link
Member

The name dnx was previously used after the rename from the K-series CLI tools (kvm et al), before all the tool names were consolidated under dotnet. Re-using that name could lead to confusion from people finding older docs or LLMs mushing up the two.

@dsplaisted
Copy link
Member

The name dnx was previously used after the rename from the K-series CLI tools (kvm et al), before all the tool names were consolidated under dotnet. Re-using that name could lead to confusion from people finding older docs or LLMs mushing up the two.

My opinion is that after 10 years it's OK to reuse the name dnx. Nowadays it's probably going to look more familiar as an analog to npx, rather than people getting confused about it because it's a name we used during previews of .NET Core.

@ErikEJ
Copy link

ErikEJ commented May 27, 2025

I have currently implemented support for running my CLI as a MCP server via a command line option.

https://github.com/ErikEJ/SqlServer.Rules/tree/master/tools/SqlAnalyzerCli#github-copilot-mcp-server-preview

Will I be able to detect if the tool has been invoked by the "exec" command, or do I need to publish another tool?

@dsplaisted
Copy link
Member

I have currently implemented support for running my CLI as a MCP server via a command line option.

https://github.com/ErikEJ/SqlServer.Rules/tree/master/tools/SqlAnalyzerCli#github-copilot-mcp-server-preview

Will I be able to detect if the tool has been invoked by the "exec" command, or do I need to publish another tool?

@ErikEJ Why would you need to detect if the tool was run via dotnet exec? What would the tool do differently?

I think that tools should behave the same whether they are run with dotnet exec, run as a local tool, or installed as a global tool. If a tool needs to behave differently in some situations then usually that should be controlled via command line arguments.

@ErikEJ
Copy link

ErikEJ commented May 27, 2025

@dsplaisted My CLI can run both as a "normal" CLI tool and a MCP server - see the link above.

@dsplaisted
Copy link
Member

@dsplaisted My CLI can run both as a "normal" CLI tool and a MCP server - see the link above.

I think the normal CLI should also be runnable via dotnet tool exec / dnx. So the command to run the MCP would be dnx ErikEJ.DacFX.TSQLAnalyzer.Cli -mcp, while dnx ErikEJ.DacFX.TSQLAnalyzer.Cli would run the normal CLI.

@ErikEJ
Copy link

ErikEJ commented May 30, 2025

@dsplaisted Cool, got it, thanks

…s, these action items were covered.

For dotnet tool exec:
Clarify that tools executed via dotnet tool exec will be installed to the NuGet cache without adding them to a manifest.
Remove the line about only tools that support direct execution being supported.
Break out the discussion about calling by command into a separate section, noting that further discussion and feedback are needed.
For dnx:
Clarify that the DNX command will forward all parameters directly to .NET, avoiding logic in shell scripts.
Update documentation to reflect that on Unix, the DNX script does not need a file extension and should be marked as executable.
Add a consideration about potentially AOTing the DNX command in the future.
…cussion.

Specifically, call out the versionless nature of the dnx script and why we're doing a dotnet dnx CLI command.
Clarify that we should execute a local version of the tool if available.
Add including of @ command support
Added comment about npx inspiration
Co-authored-by: Jan Jones <jan.jones.cz@gmail.com>
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.

8 participants