Skip to content
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

Feature request: Consistent way to run dotnet tools regardless if installed as global or as local tool #14626

Open
augustoproiete opened this issue Nov 20, 2020 · 0 comments

Comments

@augustoproiete
Copy link

As of this writing, given a developer published a dotnet tool that uses, for example, a command name "hello" (i.e. <ToolCommandName>hello</ToolCommandName>), the way to execute the tool is different depending on how the user installed the tool

  • If the user installed as a global tool, they can only run it using hello
  • If the user installed as a local tool, they can only run it using either dotnet hello or dotnet tool run hello

This makes it difficult for build scripts/systems to execute dotnet tools where they cannot control how the user installed it.

i.e. If a build script runs dotnet hello or dotnet tool run hello it should Just Work™ without the build script having any knowledge if the tool was installed globally or locally.

Request

When running dotnet <toolname> or dotnet tool run <toolname> try to run a local tool first, and fallback to a global tool with the same name.

If multiple tools with the same name are resolved, pick the one that is closer.


Repro steps

Install a dotnet tool that does not have the dotnet- prefix as a local tool:

mkdir repro-local
cd repro-local
dotnet new tool-manifest --force
dotnet tool install exceldna-unpack --version 2.0.0

✅ Both ways of executing the tool work

dotnet exceldna-unpack
# (success)

dotnet tool run exceldna-unpack
# (success)

❌ Executing the tool directly does not work

exceldna-unpack
# (error)

Install a dotnet tool that does not have the dotnet- prefix as a global tool:

dotnet tool install --global exceldna-unpack --version 2.0.0

❌ Both commands fail and the tool is not found

dotnet exceldna-unpack
# (error)

dotnet tool run exceldna-unpack
# (error)

✅ Executing the tool directly works

exceldna-unpack
# (success)
knocte added a commit to nblockchain/NOnion that referenced this issue Dec 27, 2022
belav added a commit to belav/csharpier that referenced this issue Jan 26, 2025
If a tool has a command of `csharpier` then to invoke it as a local tool
you need to use `dotnet csharpier`. Only a globally installed tool works
with `csharpier`. It doesn't seem worth the trouble to change the
command because of that.

If dotnet/sdk#14626 is done, this can be
revisited.

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

No branches or pull requests

2 participants