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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more