Dagger-dotnet cli uses the tool directive

Keywords: C# Operation & Maintenance .NET IDE DotNet


1. List of Instructions

Instruction Details

>dotnet tool -h
Description:
  Install or use extensions .NET Experience the tools.

Usage:
  dotnet [options] tool [command]

Options:
  -?, -h, --help  Displays command line help.

Commands:
  install <PACKAGE_ID>    Install global or local tools. Local tools will be added to the list and restored.
  uninstall <PACKAGE_ID>  Uninstall global or local tools.
  update <PACKAGE_ID>     Update global tools.
  list                    List globally or locally installed tools.
  run <COMMAND_NAME>      Run local tools.
  search <Search term>            stay nuget.org Medium Search dotnet tool
  restore                 Restore the tools defined in the local tool list.

2. Tool List

View installation list

>dotnet tool list -h
Description:
  List globally or locally installed tools.

Usage:
  dotnet [options] tool list

Options:
  -g, --global        Lists the tools installed for the current user.
  --local             Lists the tools installed in the local tool list.
  --tool-path <PATH>  A directory containing tools to list.
  -?, -h, --help      Displays command line help.

net 6 The above instruction structure should be dotnet tool list [options], the same as other instructions, executed as follows:

>dotnet tool list -g
 package ID                      Edition         command
-----------------------------------------------
dotnet-ef                 5.0.4      dotnet-ef
redth.net.maui.check      0.8.6      maui-check

3. Query Tools

Query input uses search directive

>dotnet tool search -h
Description:
  stay nuget.org Medium Search dotnet tool

Usage:
  dotnet [options] tool search <Search term>

Arguments:
  <Search term>  package ID Or search terms in package description. At least one character is required.

Options:
  --detail        Displays detailed results of the query.
  --skip <Skip>   Number of results to skip for paging.
  --take <Take>   Number of results to return for paging.
  --prerelease    Determining whether to include pre-release packages.
  -?, -h, --help  Displays command line help.

Query tool redth.net.maui.check, returned without showing details, latest version.

>dotnet tool search redth.net.maui
 package ID                      Latest version       author         download         Verified
--------------------------------------------------------------
redth.net.maui.check      0.8.6      Redth      60500

Show the detailed version, using detail, as follows:

>dotnet tool search redth.net.maui --detail
----------------
redth.net.maui.check
 Latest version: 0.8.6
 author: Redth
 sign:
download: 60500
 Verified: False
 Explain: A dotnet tool for helping set up your .NET MAUI environment
 Edition:
        #Omit some old content
        0.7.3 download: 5410
        0.7.5 download: 86
        0.7.6 download: 174
        0.7.7 download: 3173
        0.8.0 download: 90
        0.8.1 download: 131
        0.8.2 download: 304
        0.8.4 download: 4808
        0.8.5 download: 815
        0.8.6 download: 3202

Show partial query results

>dotnet tool search redth.net.maui --skip 0 --take 30
 package ID                      Latest version       author         download         Verified
--------------------------------------------------------------
redth.net.maui.check      0.8.6      Redth      60500

IV. Installation Tools

Installation uses instructions install, which are divided into current directory installation and global installation.

4.1. Current Directory Installation

The default installation requires the user to create a tool manifest, and the user creates a manifest file by executing dotnet new tool-manifest at the root directory where the tool is currently required.

Common error messages for not creating a manifest are as follows:

The manifest file could not be found.
To get a list of locations that have been searched, specify before the tool name "-d" Options.
If you plan to install global tools, add them to the command `--global`. 
If you want to create a list, use `dotnet new tool-manifest`,Usually in the root directory of the repository.

Create a tool configuration file for the current directory with the following instructions:

>dotnet new tool-manifest --force
 Template successfully created Dotnet Local tool manifest file".
>tree .
Folders for Volume Document Volumes PATH list
 Volume serial number is 9813-5795
E:\STUDY\DEMO\DOS
└─.config

In the.config folder, generate a dotnet-tools.json, starting with the following:

{
  "version": 1,
  "isRoot": true,
  "tools": {}
}

Install and configure the software inventory for the current directory. The default installation is the latest version. You can specify the version using --version xxx as follows:

>dotnet tool install redth.net.maui.check
 You can call tools from this directory using the following commands: "dotnet tool run maui-check" or "dotnet maui-check". 
Tool " redth.net.maui.check"(Version "0".8.6")Successfully installed. Entries will be added to the manifest file xxxx\.config\dotnet-tools.json Medium.
# Specified version
>dotnet tool install redth.net.maui.check --version  0.8.4
 You can call tools from this directory using the following commands: "dotnet tool run maui-check" or "dotnet maui-check". 
Tool " redth.net.maui.check"(Version "0".8.4")Successfully installed. Entries will be added to the manifest file E:\Study\Demo\Dos\.config\dotnet-tools.json Medium.

The corresponding configuration list is as follows:

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "redth.net.maui.check": {
      "version": "0.8.6",
      "commands": [
        "maui-check"
      ]
    }
  }
}

Look at the list, and the output is as follows:

>dotnet tool list
 package ID                      Edition         command              Detailed list
------------------------------------------------------------------------------------------------
redth.net.maui.check      0.8.6      maui-check      xxxx\.config\dotnet-tools.json

4.2, Global Installation

Without creating an inventory in a specific directory, use a global installation with the -g command added at the end of install as follows:

>dotnet tool install -g  redth.net.maui.check --version  0.8.4
 Tools can be invoked using the following commands: maui-check
 Successfully installed tool " redth.net.maui.check"(Version "0".8.4"). 

View the list of tools as follows:

>dotnet tool list -g
 package ID                      Edition         command
-----------------------------------------------
redth.net.maui.check      0.8.4      maui-check

5. Update Tools

The update directive is update, which is also divided into the current tool list and global updates. Updates default to update to the latest version, which can be updated through --version.

The current directory is updated with the following instructions:

>dotnet tool update redth.net.maui.check --version  0.8.5
 Tool " redth.net.maui.check"Successfully from version "0".8.4"Update to version "0".8.5"(Inventory File xxx\.config\dotnet-tools.json). 

Global update with the following instructions:

>dotnet tool update -g redth.net.maui.check --version  0.8.5
 Tool " redth.net.maui.check"Successfully from version "0".8.4"Update to version "0".8.5". 

6. Uninstallation Tools

Uninstall uses the uninstall directive, defaults to the current catalog tool manifest tool uninstall, and adds-g to uninstall the global tool.

>dotnet tool uninstall  redth.net.maui.check -g
 Tool successfully uninstalled redth.net.maui.check"(Version "0".8.5").

Posted by imarockstar on Sun, 19 Sep 2021 19:35:38 -0700