-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a one-shot execution mode for .NET tools a la npx #31103
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
Comments
Requirements
CLI InterfaceIn general, we should reuse as many relevant flags from the existing tool install commands as possible. Keep
Consider
Ignore
ProcessWhen a user runs
Invoking the toolThere are two main alternatives here
They have their pros and cons. If we do |
what about |
@timheuer |
I would support adding a 'latest' option if you go the path of preferring local (any version) -> global (any version) -> downloading (latest) to the temp folder (cached), if no version is specified. I would also support adding a version and respecting that, as well as doing tool@version. |
Shorthand suggestions from @dsplaisted: |
Have we thought about how to treat the difference between the tool package name and the command name? I think it's common for those to be different, for example:
Today, you use the package name to install the tool, but the command name to invoke it. How should we handle this with one-shot execution mode? |
The way it currently works on my pr is like that. We use the package name to install, and the command name (retrieved from the package data) to execute. |
There are a few options:
|
We currently only support one command per tool package. But it seems like it will be confusing to have to use I think it also means that the idea of automatically using one-shot mode (with prompting) if the specified tool isn't installed locally or globally doesn't make as much sense, because the names won't match. Do npm and uv support a different command name from the package name, or do they always have to match? Ideas to solve:
|
If we're doing this inside the run command, I think it is important to try and prioritize the command name over the package name for those reasons. I am curious if we could do something like: dotnet tool run <command> --from-source-package=<name[@version]> <args> That way, we respect the current behavior of the run command while at the same time explicitly specifying the package name to be run in one-shot mode. We can even make the command argument optional when passed the |
I think we want to try to make it so that people don't have to think about the difference between the tool package name and the command name. I think we could probably have a prioritized list of conventions we follow to look up a package name based on the command name. Browsing through the tool packages on NuGet, we might use some of the following conventions for the package name:
|
Probing different names allows someone to hijack a name (or introduce ambiguity). |
I think
|
I agree mostly but am not sure about the |
Is your feature request related to a problem? Please describe.
Currently to use a .NET global tool that may or may not be installed, you need to perform a series of steps
And for local tools, you need to
When all you really want to do is
We should consider adding a mode of running a .NET tool that combines all of these steps into one user-facing step.
Describe the solution you'd like
Something akin to
that would combine all of the preceding steps into one logical command. The tool would be installed (locally by default, creating a manifest if necessary), executed passing along whatever args, and then optionally being uninstalled after execution. If a version was supplied and the locally-available version of the tool (if any) doesn't satisfy that version, the specified version would be installed.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: