BT

Exploring Global Tools in .NET Core

| by Jeff Martin Follow 17 Followers on Mar 16, 2018. Estimated reading time: 1 minute |

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 Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT