Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

[BUG] Dotnet new extra arguments do not work with custom dotnet library template #783

@md-owes

Description

@md-owes

Current Behavior

I have created two custom dotnet templates. one named "jaamapi" which is a template to create custom dotnet webapi project and another named "jaamdom" to create custom dotnet library project. Both templates require additional arguments to be passed. When i execute these commands directly as dotnet commands, they work as shown below

dotnet new jaamapi -n ProgramService.API -N ProgramService -E Program -L program
dotnet new jaamdom -n ProgramService.Domain -o Domain -N ProgramService -E Program -L program

But when executing these commands via nx-dotnet, the first command executes successfully and provides the expected output whereas the second fails to execute with an error as shown in Failure Logs section.

Nx Dotnet command that

works

nx g @nx-dotnet/core:app --name ProgramService --tags ps --directory ProgramService --template jaamapi --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none --verbose --args='-N=ProgramService,-E=Program,-L=program'

throws below error

nx g @nx-dotnet/core:lib --name Domain --tags ps --directory ProgramService --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none --verbose --args='-N=ProgramService,-E=Program,-L=program'

From error it is evident that the nx-dotnet library does not parse the additional arguments the same way as the nx-dotnet application works.

Expected Behavior

The library creation command using nx, i.e. @nx-dotnet/core:lib, should work with additional arguments just the way @nx-dotnet/core:app works.

Github Repo

No response

Steps to Reproduce

  1. you need to create two custom dotnet templates as mentioned in MSDN docs
  2. once the templates are created and installed locally on your system, you can test it using dotnet new command
  3. Once the previous step is successful, now execute nx-dotnet commands for both templates, you need to ensure that first nx command should be an application and the other a library
  4. Now, you can observe that the library command fails with similar error as mentioned in description

Nx Report

NX   Report complete - copy this into the issue template

   Node   : 20.8.0
   OS     : win32-x64
   npm    : 10.1.0

   nx (global)    : 16.9.1
   nx             : 16.9.1
   @nx/js         : 16.9.1
   @nx/linter     : 16.9.1
   @nx/workspace  : 16.9.1
   @nx/devkit     : 16.9.1
   @nrwl/devkit   : 15.8.5
   @nrwl/tao      : 16.9.1
   nx-cloud       : 16.4.0
   typescript     : 4.9.5
   ---------------------------------------
   Community plugins:
   @nx-dotnet/core : 1.23.0
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/devkit@15.8.5

   To fix this, run `nx migrate nx@16.9.1`

nx.json

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": [
          "build",
          "lint",
          "test",
          "e2e",
          "codegen",
          "swagger"
        ]
      }
    }
  },
  "targetDefaults": {
    "build": {
      "dependsOn": [
        "^build",
        "codegen",
        "^codegen"
      ],
      "inputs": [
        "production",
        "^production"
      ]
    },
    "lint": {
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/.eslintignore"
      ]
    },
    "test": {
      "inputs": [
        "default",
        "^production",
        "{workspaceRoot}/jest.preset.js"
      ]
    }
  },
  "namedInputs": {
    "default": [
      "{projectRoot}/**/*",
      "sharedGlobals"
    ],
    "production": [
      "default",
      "!{projectRoot}/.eslintrc.json",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/jest.config.[jt]s",
      "!{projectRoot}/src/test-setup.[jt]s",
      "!{projectRoot}/test-setup.[jt]s"
    ],
    "sharedGlobals": []
  },
  "plugins": [
    "@nx-dotnet/core"
  ]
}

Failure Logs

NX  Generating @nx-dotnet/core:library

Executing Command: dotnet "new" "jaamdom" "--language" "C#" "--name" "ProgramService.Domain" "--output" "program-service/Domain" "-" "N" "=" "P" "r" "o" "g" "r" "a" "m" "S" "e" "r" "v" "i" "c" "e" "," "-" "E" "=" "P" "r" "o" "g" "r" "a" "m" "," "-" "L" "=" "p" "r" "o" "g" "r" "a" "m"
Error: Invalid option(s):
-
   '-' is not a valid option
N
   'N' is not a valid option
=
   '=' is not a valid option
P
   'P' is not a valid option
r
   'r' is not a valid option
o
   'o' is not a valid option
g
   'g' is not a valid option
a
   'a' is not a valid option
m
   'm' is not a valid option
S
   'S' is not a valid option
e
   'e' is not a valid option
v
   'v' is not a valid option
i
   'i' is not a valid option
c
   'c' is not a valid option
,
   ',' is not a valid option
E
   'E' is not a valid option
L
   'L' is not a valid option
p
   'p' is not a valid option

For more information, run:
   dotnet new jaamdom --language C# -h

For details on the exit code, refer to https://aka.ms/templating-exit-codes#127

NX   dotnet execution returned status code 127


Error: dotnet execution returned status code 127
    at DotNetClient.logAndExecute (E:\REPO\ADO\Jaameah\JaameahBack\node_modules\@nx-dotnet\dotnet\src\lib\core\dotnet.client.js:230:19)
    at DotNetClient.new (E:\REPO\ADO\Jaameah\JaameahBack\node_modules\@nx-dotnet\dotnet\src\lib\core\dotnet.client.js:21:21)
    at E:\REPO\ADO\Jaameah\JaameahBack\node_modules\@nx-dotnet\core\src\generators\utils\generate-project.js:116:25
    at Generator.next (<anonymous>)
    at fulfilled (E:\REPO\ADO\Jaameah\JaameahBack\node_modules\tslib\tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Additional Information

I have tried to play around with additional argument syntax as shown

nx g @nx-dotnet/core:lib --name Domain --tags ps --directory ProgramService --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none --verbose --args='-N ProgramService,-E Program,-L program'

nx g @nx-dotnet/core:lib --name Domain --tags ps --directory ProgramService --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none --verbose --args='-N ProgramService -E Program -L program'

nx g @nx-dotnet/core:lib --name Domain --tags ps --directory ProgramService --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none --verbose --args '-N ProgramService -E Program -L program'

nx g @nx-dotnet/core:lib --name Domain --tags ps --directory ProgramService --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none --verbose -- '-N ProgramService -E Program -L program'

nothing worked so far.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions