NSwag: Nswag 14 CLI /runtime argument not running with Net80
Runtime specified in nswag.json as “Net80”.
Not quite sure if it’s needed in both places, but did it to make sure.
Then run the Nswag CLI tool (npm i -g nswag@14) run command:
> nswag run ..\..\..\WebServiceProjects\WebService.PortalApi\nswag.json
NSwag NPM CLI
NSwag command line tool for .NET Core Net70, toolchain v14.0.0.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory: C:\Users\Dylan\AppData\Roaming\nvm\v18.18.0\node_modules\nswag\bin\binaries\Net80
Executing file '..\..\..\WebServiceProjects\WebService.PortalApi\nswag.json' with variables ''...
System.InvalidOperationException: The specified runtime in the document (Net80) differs from the current process runtime (Net70). Change the runtime with the '/runtime:Net80' parameter or run the file with the correct command line binary.
at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in /_/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 69
at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in /_/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 33
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in /_/src/NSwag.Commands/NSwagCommandProcessor.cs:line 62node:child_process:965
throw err;
^
Error: Command failed: dotnet "C:\Users\Dylan\AppData\Roaming\nvm\v18.18.0\node_modules\nswag\bin/binaries/Net80/dotnet-nswag.dll" run ..\..\..\WebServiceProjects\WebService.PortalApi\nswag.json
at checkExecSyncError (node:child_process:890:11)
at Object.execSync (node:child_process:962:15)
at C:\Users\DylanvanderMerwe\AppData\Roaming\nvm\v18.18.0\node_modules\nswag\bin\nswag.js:64:27
at ChildProcess.exithandler (node:child_process:414:7)
at ChildProcess.emit (node:events:517:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:303:5) {
status: 4294967295,
signal: null,
output: [ null, null, null ],
pid: 73448,
stdout: null,
stderr: null
}
Alright then let’s set the /runtime parameter with the CLI:
> nswag run ..\..\..\WebServiceProjects\WebService.PortalApi\nswag.json /runtime:Net80
NSwag NPM CLI
NSwag command line tool for .NET Core Net70, toolchain v14.0.0.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory: C:\Users\Dylan\AppData\Roaming\nvm\v18.18.0\node_modules\nswag\bin\binaries\Net80
NConsole.UnusedArgumentException: Unrecognised arguments are present: [/runtime:Net80]
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in /_/src/NSwag.Commands/NSwagCommandProcessor.cs:line 62node:child_process:965
throw err;
^
Error: Command failed: dotnet "C:\Users\Dylan\AppData\Roaming\nvm\v18.18.0\node_modules\nswag\bin/binaries/Net80/dotnet-nswag.dll" run ..\..\..\WebServiceProjects\WebService.PortalApi\nswag.json /runtime:Net80
at checkExecSyncError (node:child_process:890:11)
at Object.execSync (node:child_process:962:15)
at C:\Users\DylanvanderMerwe\AppData\Roaming\nvm\v18.18.0\node_modules\nswag\bin\nswag.js:57:19
at ChildProcess.exithandler (node:child_process:414:7)
at ChildProcess.emit (node:events:517:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:303:5) {
status: 4294967295,
signal: null,
output: [ null, null, null ],
pid: 32788,
stdout: null,
stderr: null
}
The correct runtime is specified in the config file.
It seems like there is an issue with the CLI. Please advise how to get this working as after updating to net80 we cannot use nswag via the CLI to generate Typescript.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 17
- Comments: 17 (4 by maintainers)
Removing passed runtime argument in nswag.cmd works for me.
Still an issue in 14.0.8. Running from the command line without /runtime:Net80 tells you to add it. Running with it tells you to remove it.
nswag run file.nswag.jsonnswag run file.nswag.json /runtime:Net80Renaming the file to file.nswag and then running this does work:
nswag run /runtime:Net80remove
/runtime:Net80for
runcommandruntimeis supported but only for default config files (so it will take defaultnswag.jsonor*.nswagfiles)As mentioned in log, cmd is using
Net70instead ofNet80I think, #4680 should resolve this issueHere’s how i got it to work bypassing the error ‘t_he specified runtime in the document (Net80) differs from the current process runtime…_’ using the cli version 14.2.0. My .net core Api is .NET core 8. However the cli is expecting .net core 9. After reviewing a bit the source code of the cli, i realized that the runtime inside the .nswag must be Net90. So i changed the runtime to Net90(e.g.:“runtime”: “Net90”) as displayed in the following image: