Dotnet tools - is a great technology to distribute command line tools.
For example, the following command installs EF Core CLI.
dotnet tool install --global dotnet-ef
Listing installed dotnet tools:
dotnet tool list --global
Uninstalling dotnet tool:
dotnet tool uninstall --global dotnet-ef
You can pack your own command line application as dotnet tool:
dotnet pack MyCli.csproj --configuration Release --output ./publish`
-p:PackAsTool=true `
-p:ToolCommandName=mytool `
-p:Version=1.0.0
It generates MyCli.1.0.0.nupkg
nuget package.
Built tool with be placed into tools\net7.0\any
folder of the archive.
You can push the package into nuget repository as normal nuget package and install the tool from it.
But you can also install the tool from a local folder where nupkg file placed:
dotnet tool install MyCli --global --add-source ./publish
The dotnet tool
is a part of .Net Core SDK, so you can't install your tool the environment where no dotnet SDK installed. But you can install dotnet tool to environment with SDK installed and copy it from there. Check the Andey Lock example for copying dotnet tool binaries to non-sdk docker image.
Top comments (0)