. Net Core Development Log--global Tools

Source: Internet
Author: User
Tags dotnet

. Net Core 2.1 introduces a new feature, the essence of which is the NuGet package that contains the console application, and for now, there are no particularly useful tools, but it is believed that over time, a variety of creative or practical Global Tools will appear in everyone's eyes.

Installing a global tools is simple, enter a command dotnet tool install -g dotnetsay , the tool named Dotnetsay is already installed in a specific directory.

OS Path
Linux/macos $HOME/.dotnet/tools
Windows %userprofile%.dotnet\tools

If you want to use a tool, you need to enter the command for the tool, such as dotnetsay :

While global tools is part of the NuGet package, it is difficult to find out the many NuGet packages because the NuGet Web site does not specifically classify it, so it is not known by its name. A better approach is to find the tools you need in GitHub's Natemcmaster/dotnet-tools library.

Thick and thick, such as dotnet-serve,dotnet-search,dotnet-md5 and other individuals think it is very useful.

However, some tools will display errors that are not found in the specified version of the framework after the installation is complete. Global tools has yet to be improved in terms of compatibility.

It's not difficult to create a global tools yourself.

Because global tools is actually a console application, the first is the new one. dotnet new consoel -o helloGlobalTools.

The code content is simple, displaying a string of characters containing the current time:

using System;namespace helloGlobalTools{    class Program    {        static void Main(string[] args)        {            Console.WriteLine($"Hello {DateTime.Now}");        }    }}

You need to join within the PropertyGroup node in the csproj file <PackAsTool>true</PackAsTool> .

dotnet packthe HELLOGLOBALTOOLS.1.0.0.NUPKG installation package file can be generated under the Bin\Debug directory by command.

Switch the current directory to the path to the file, and then execute the Global Tools installation command dotnet tool install -g helloGlobalTools --add-source ./ . After the installation is complete, you can also dotnet tool list -g confirm that the installation was successful.

Finally, enter your tool command name to get the desired result.

Of course, if you have confidence in your work and want to share it with others, you can upload the NuGet package to Nuget.org's official website. The result of your labor will be able to maximize the value of the play.

Reference Documentation:

Global-tools

. Net Core Development Log--global Tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.