sdk: Cannot run global tool after installing it, must open new command prompt
After I have successfully installed a global tool I am not able to run it without opening a new command prompt:
C:\Users\daroth\Desktop\test>dotnet install tool dotnet-dev-certs --version 2.1.0-preview1-28051
The installation succeeded. If there is no other instruction. You can type the following command in shell directly to invoke: dotnet-dev-certs
C:\Users\daroth\Desktop\test>dotnet dev-certs -h
No executable found matching command "dotnet-dev-certs"
C:\Users\daroth\Desktop\test>dotnet-dev-certs -h
'dotnet-dev-certs' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\daroth\Desktop\test>dotnet dev-certs
No executable found matching command "dotnet-dev-certs"
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 49 (7 by maintainers)
Commits related to this issue
- GLobal tools are now installed and used in the same script block, as suggested here: https://github.com/dotnet/cli/issues/8368#issuecomment-424852996. — committed to satrapu/aspnet-core-logging by satrapu 6 years ago
- call dotnet tools with script AB#9 see: https://github.com/dotnet/cli/issues/8368#issuecomment-424852996 https://github.com/ignatandrei/stankins/blob/master/azure-pipelines.yml — committed to cnrun/strava-x-api by cnrun 5 years ago
I’ve the same error when using
dotnet tool install --global ***in the new Azure Pipelines flow.My command is like:
This command outputs this:
And the next step will fail (running the above command in the same step or a different script step make no difference)
@wli3 in an automated scenario like Azure pipelines(previously VSTS) this is a big problem. There is no way to open a new shell to mitigate this. Also, just adding a better message does not solve this problem. Why does dotnet tool require this extra manual step? Npm works just fine. At the minimum,
dotnet tool install -gshould be adding the location to PATH. Can we re-activate this issue?Hi @dasMulli ; keep seeing you everywhere… Hi @wli3 : thanks for your solution.
For now I just solved it by providing the full path to the executable, so:
See also linked issue https://github.com/Microsoft/vsts-tasks/issues/8291
IDK why this issued has been closed. It still doesn’t work in an Azure pipeline, e.g. I can’t run AzureSignTool:
For now, using
dotnet tool install --tool-pathto install it locally as a workaround:Updated for those who may end up here, like me again in 2023.
Eventually, instead of
dotnet tool update --tool-path <local-path>I settled on usingdotnet tool install --local.For example:
This creates/updates the local file
./.config/dotnet-tools.json:Make sure
./.config/dotnet-tools.jsonis tracked in your project’s repo.At any time you can restore your local dotnet tools with:
I’m using this approach in my project’s CI/CD pipleline and it gives me reliable & reproducible builds.
I am facing the same issue: I’m in a Docker container, at build time on our build server.
@KathleenDollard It should be trivial to update the PATH of the current shell session in addition to the system one.
Some problem here . However, in old VSTS pipelines it works. It Azure DevOps it does not.
You could add
%UserProfile%/.dotnet/tools/to your path before running the command. Although, in script, we recommend using--too-pathwith explicit location instead of install it globally. And call the tool with full path.+1 for the tool path. an example vsts / azure pipelines config usage can bee seen in msbuild: https://github.com/Microsoft/msbuild/blob/542125d86fca51bbfce5cebd6f3efd3bb36549b0/.vsts-dotnet.yml#L28-L39
@dasMulli Something similar is added. However, I think it is not working properly due to, in Windows it cannot distinguish between what will be available(in registry) and what is available in the session
@satrapu Thanks for that. Having another way is good to know. There’s a catch in what you wrote above, it is working as a byproduct of the .NET Core install by updating PATH. It just so happens you are doing a specific version install to make that happen rather than exporting the tools folder to the path. One thing to consider - outside of that workaround a local tools folder may be faster and easier than managing/updating version information and an additional SDK install task. I can simplify by using a local tool, your scenario may not allow that though.
vs
Yes.