Skip to content

Add "dotnet dnx" command as alias for "dotnet tool execute" #49425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2025

Conversation

dsplaisted
Copy link
Member

This adds a root dotnet dnx command which forwards to dotnet tool execute. This will enable us to add a dnx shell script which calls dotnet dnx.

dsplaisted and others added 2 commits June 16, 2025 08:53
… something.

This won't allow those commands to show up in subcommand-help of their parents, however.
@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 20:39
@dsplaisted dsplaisted requested a review from a team as a code owner June 16, 2025 20:39
@dsplaisted dsplaisted requested a review from a team June 16, 2025 20:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for a hidden dotnet dnx alias that forwards to dotnet tool execute, integrates it into the CLI parser, and adjusts help generation to surface the new command.

  • Registers the new dnx command in Parser.cs
  • Implements DnxCommandParser to mirror arguments/options for forward execution
  • Modifies HelpBuilder.cs to stop skipping hidden commands so dnx appears in help

Reviewed Changes

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

File Description
src/Cli/dotnet/Parser.cs Imported and registered DnxCommandParser; reorganized help option handling
src/Cli/dotnet/Commands/Dnx/DnxCommandParser.cs New hidden dnx command that forwards to ToolExecuteCommand
src/Cli/Microsoft.TemplateEngine.Cli/Help/HelpBuilder.cs Removed skip for hidden commands to allow help for dnx
Comments suppressed due to low confidence (3)

src/Cli/Microsoft.TemplateEngine.Cli/Help/HelpBuilder.cs:45

  • The check to skip hidden commands was removed, causing hidden commands (like dnx) to appear in help for all commands. Consider reintroducing if (context.Command.Hidden) { return; } or conditionally checking the alias so other hidden commands stay hidden.
foreach (var writeSection in GetLayout(context))

src/Cli/dotnet/Commands/Dnx/DnxCommandParser.cs:20

  • There are no tests added to verify that dotnet dnx correctly forwards to the underlying dotnet tool execute. Please add unit or integration tests to cover this new alias behavior.
Command command = new("dnx", CliCommandStrings.ToolExecuteCommandDescription);

src/Cli/dotnet/Parser.cs:314

  • [nitpick] The root help text (CliUsage.HelpText) likely needs updating to mention the new dnx alias so users know it’s available and how it maps to dotnet tool execute.
Console.Out.WriteLine(CliUsage.HelpText);

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely like having a shorthand. That's awesome.

Before the .NET CLI / .NET SDK existed, the tool that used to be the SDK was called dnx. I worry this will result in name confusion and would prefer to use dntx, though I am not the 'decision maker' on this.


private static Command ConstructCommand()
{
Command command = new("dnx", CliCommandStrings.ToolExecuteCommandDescription);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baronfel Is this the only way to alias nested commands? Meaning, @dsplaisted is taking what is execute nested in tool, creating this composition of it called dnx, and then exposing that as a new command. I'm assuming aliasing execute would end up with dotnet tool dnx. Also, does this composition work with the shell completion stuff since the options and arguments are copied over?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commands can have aliases, but only at the 'same level'. This kind of sub-level redirect isn't natively supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the shell completion perspective this is an entirely new command with separate completions. If we had some more 'full' concept of aliases then the completion generation could perhaps handle that more intelligently.

@dsplaisted
Copy link
Member Author

I definitely like having a shorthand. That's awesome.

Before the .NET CLI / .NET SDK existed, the tool that used to be the SDK was called dnx. I worry this will result in name confusion and would prefer to use dntx, though I am not the 'decision maker' on this.

See my response here: dotnet/designs#334 (comment)

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.

My sense is that dnx is the more popular option, both from external feedback and from leaders on our team.

@baronfel, do you think this is correct or am I just projecting my own opinion?

@nagilson
Copy link
Member

nagilson commented Jun 17, 2025

I think that's valid. preview 6 has snapped, so we may want to change the target branch if we can still get this in. I will bring this up in triage. Thanks for considering my feedback :)

@nagilson nagilson added the needs team triage Requires a full team discussion label Jun 17, 2025
@marcpopMSFT marcpopMSFT removed the needs team triage Requires a full team discussion label Jun 17, 2025
@dsplaisted dsplaisted merged commit 5331567 into dotnet:main Jun 17, 2025
32 checks passed
@marcpopMSFT
Copy link
Member

Triage: tool exec was the critical piece we wanted for P6. This is nice to have and we can wait for preview 7 when we can get dnx in for zip and admin installs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants