DEV Community

Cover image for Using dotnet tool
Alexey Ryazhskikh
Alexey Ryazhskikh

Posted on

4

Using dotnet tool

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
Enter fullscreen mode Exit fullscreen mode

Listing installed dotnet tools:

dotnet tool list --global
Enter fullscreen mode Exit fullscreen mode

Uninstalling dotnet tool:

dotnet tool uninstall --global dotnet-ef
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay