dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.07k forks source link

global tools do not work #43171

Closed rwb196884 closed 1 week ago

rwb196884 commented 2 months ago
PS C:\Work\Azure\Foo> dotnet tool install --global Swashbuckle.AspNetCore.Cli
Tools directory 'C:\Users\bar\.dotnet\tools' is not currently on the PATH environment variable.

You can add the directory to the PATH by running the following command:

setx PATH "%PATH%;C:\Users\bar\.dotnet\tools"

Tool 'swashbuckle.aspnetcore.cli' was reinstalled with the stable version (version '6.7.3').
PS C:\Work\Azure\Foo> setx PATH "%PATH%;C:\Users\bar\.dotnet\tools"

SUCCESS: Specified value was saved.
PS C:\Work\Azure\Foo> dotnet tool run swagger tofile --output C:\Work\Azure\Foo\Buz\wwwroot/Buz.json C:\Work\Azure\Foo\Buz\bin\Debug\net8.0\Buz.dll truth_portal
Cannot find a tool in the manifest file that has a command named 'swagger'.
PS C:\Work\Azure\Foo>
KalleOlaviNiemitalo commented 2 months ago

dotnet tool run is for local tools; you installed the tool as global.

baronfel commented 1 week ago

@KalleOlaviNiemitalo is correct - when a tool is installed globally then an executable shim is installed to the tools directory and we expect users to invoke it via that shim. In this case, you'd use swagger:

>swagger
Swashbuckle (Swagger) Command Line Tools
Commands:
  tofile:  retrieves Swagger from a startup assembly, and writes to file
rwb196884 commented 1 week ago

Isn't it really confusing to have two different ways to run the same command depending on how the command was installed?