BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Exploring Global Tools in .NET Core

Exploring Global Tools in .NET Core

Leia em Português

This item in japanese

One of the new features to debut in .NET Core 2.1 Preview was Global Tools.  Global Tools provides a way to write .NET Core console apps that can be packaged and delivered as NuGet packages.  If .NET Core runs on the target platform, then a properly packaged Global Tool will work there.  JavaScript developers may find it interesting to note that this tooling is directly inspired by NPM global tools.

Ultimately .NET Core Global Tools will support installation into a user’s local directory, but in the current preview release a given tool must be installed globally for all users on the system.  Installation of a Global Tool is done via the following command:

dotnet install tool -g example

To remove an installed .NET Core tool, it must be manually deleted from its installation directory.  On Windows systems that is:

%USERPROFILE%\.dotnet\tools

On Linux systems that is:

    ~/.dotnet/tools

Microsoft has provided samples of a global tool in the dotnet repo, including dotnetsay which can be reviewed as a sample implementation.  For a bit more of an in-depth sample, Alexander Tsvetkov has put together a helpful walkthrough on to create a global tool from scratch.  This doubles as an example of why the global tool is helpful: in this case he puts together a simple static file web server that can be executed from any directory (which can be useful for development purposes).

Coming in future releases is the ability to install the tools in a single user profile and the ability to uninstall previously installed tools.  In reviewing what npm global tools offers, it would seem plausible that gaining the ability to update installed tools would also be forthcoming.

To try out Global Tools for yourself, .NET Core 2.1 Preview must be installed on your system.

Rate this Article

Adoption
Style

BT