templating How does --target-framework-override work? The templates suggest it should be --TargetFrameworkOverride - Csharp

I can't understand why --target-framework-override is the acceptable parameter with dotnet new console. According to the template:

  "symbols": {
    "TargetFrameworkOverride": {
      "type": "parameter",
      "description": "Overrides the target framework",
      "replaces": "TargetFrameworkOverride",
      "datatype": "string",
      "defaultValue": "",
      "displayName": "Target framework override"
    },

The parameter should be --targetframeworkoverride, yet when you try that, it gives an error stating the parameter doesn't exist. Can someone explain this?

Asked Oct 14 '21 08:10
avatar Thraka
Thraka

1 Answer:

@Thraka

It is possible to define short (with -) and long (with --) option override in dotnetcli.host.json file located along with template.json

{
  "$schema": "http://json.schemastore.org/dotnetcli.host",
  "symbolInfo": {
    "TargetFrameworkOverride": {
      "isHidden": "true",
      "longName": "target-framework-override",
      "shortName": ""
    },

For most of .NET templates, the host file is defining the long name override for TargetFrameworkOverride as target-framework-override. Also it hides it from help output. We also have an issue to discuss usage of this parameter in next releases, please note that it might be removed.

1
Answered Oct 04 '21 at 11:18
avatar  of vlada-shubina
vlada-shubina