Skip to content

Reserved Aliases

Vlada Shubina edited this page Nov 4, 2022 · 1 revision

Reference for dotnetcli.host.json

In dotnet new the parameter symbols are exposed as additional template options that can be passed to the command. Generally, dotnet new uses the name of parameter symbol to generate the long and the short alias for the option:

  • The long alias is a parameter symbol name with -- prefix.
  • The short alias is a parameter symbol name first character with - prefix.

Note that the aliases are case sensitive.

With dotnetcli.host.json file we can change long alias and short alias of the template option and its visibility. dotnetcli.host.json is located at the same directory as template.json file. It has the following configuration:

  • symbolsInfo
    It has a collection of the name of specified parameter symbol in template.json with corresponding long or short aliases to override original ones and the visibility of the template option.
    • longName - overrides the long alias for the parameter symbol.
    • shortName - overrides the short alias for the parameter symbol. Empty means short alias should not be used.
    • isHidden - true if the parameter should be hidden in dotnet new.
  • usageExamples - not used; see #3262 for more details.

In case when option assignment results in duplicate options, --param: prefix is used for the long alias and short alias is generated from the beginning of the symbol's name till the one which can form a unique short name with - prefix or -p: prefix is used.

Examples
Example 1

Overrides original long alias --TargetFrameworkOverride with --targetframework and overrides short alias -T with -tf.

{
  "$schema": "http://json.schemastore.org/dotnetcli.host",
  "symbolInfo": {
    "TargetFrameworkOverride": {
      "longName": "targetframework",
      "shortName": "tf"
    }
  }
}

Part of the output of dotnet new