Skip to content

Add dotnet tool exec command for one-shot tool execution #49329

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 45 commits into from
Jun 12, 2025

Conversation

dsplaisted
Copy link
Member

This is a continuation of this PR: #48443

Design doc: dotnet/designs#334
Original issue: #31103

Updates from previous PR include:

  • First check if the tool package specified is installed as a local tool. If so, download it if necessary (without needing a confirmation prompt), and run it.
  • Only show confirmation prompt if the required packages aren't already in the global packages folder.

@dsplaisted dsplaisted requested a review from a team June 10, 2025 21:44
</data>
<data name="ToolDownloadConfirmationPrompt" xml:space="preserve">
<value>Tool package {0}@{1} will be downloaded from source {2}.
Proceed? [y/n]</value>
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we could reword this to be more localization friendly. Something like Press 'y' to proceed or 'n' to decline. This way, we can translate proceed and decline, and lock the y/n keys from being localized. I imagine for non-Latin keyboards, we may need to translate the Y/N as well to display.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a good suggestion, but I personally prefer to be less verbose here.

@@ -812,4 +812,7 @@ For a list of locations searched, specify the "-d" option before the tool name.<
<value>Cannot specify --version when the package argument already contains a version.</value>
<comment>{Locked="--version"}</comment>
</data>
<data name="YesOptionDescription" xml:space="preserve">
<value>Overrides confirmation prompt with "yes" value. </value>
Copy link
Member

Choose a reason for hiding this comment

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

Should "yes" not be translated? It sounds like a specific, non-localized value.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated how the confirmation prompt works and is localiized. I think the yes string here can be localized.

toolExecutable,
commandArguments);
}
else if (toolRunner == "executable")
Copy link
Member

Choose a reason for hiding this comment

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

nit: Redundant else usage (both this else-if and the plain else).

Copy link
Member Author

Choose a reason for hiding this comment

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

It's redundant but seems a bit clearer to me like this. If you get rid of the elses you have to pay attention to the return statements inside the blocks to understand the overall flow.

@dsplaisted
Copy link
Member Author

@Forgind @joeloff @MiYanni Thanks for the reviews, I've applied some of the feedback so far and pushed those changes.

@@ -812,4 +812,7 @@ For a list of locations searched, specify the "-d" option before the tool name.<
<value>Cannot specify --version when the package argument already contains a version.</value>
<comment>{Locked="--version"}</comment>
</data>
<data name="YesOptionDescription" xml:space="preserve">
<value>Overrides confirmation prompt with "yes" value. </value>
</data>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
</data>
<comment>{Locked="yes"}</comment>
</data>

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't actually think this needs to be locked, I've updated the confirmation prompt to support localization better.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't accept imply yes (whereas decline implies no)?


if (!_interactive)
{
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Good call to default to 'no' in this instance!

Copy link
Member Author

Choose a reason for hiding this comment

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

Per @baronfel, npx does it the other way 😀. So we still might change it.

Copy link
Member

@nagilson nagilson Jun 11, 2025

Choose a reason for hiding this comment

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

Ah, that actually makes sense. No is better than no default, but I think we should change it too. It would make scripts more verbose. I don't see a scenario in CI where I'd write this but want to say no.

dsplaisted and others added 2 commits June 11, 2025 16:53
Co-authored-by: Michael Yanni <MiYanni@microsoft.com>
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.

Thanks for sprucing up the code in some places. I read through everything and couldn't find any issues in the logic with the time we have before preview 6 snaps. All of the remaining feedback seems like nits to me - good feedback yet not blocking. Very excited to see this feature rollout :)

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

Successfully merging this pull request may close these issues.

8 participants