5

So I have this NSWAG file that works since forever, suddenly today without changing anything it throws this error:

call npm install -g nswag

changed 1 package in 4s
NSwag NPM CLI
NSwag command line tool for .NET Core Net60, 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\[...]\nswag\bin\binaries\Net60
NConsole.UnusedArgumentException: Unrecognised arguments are present: [/runtime:Net60]
   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 61node:child_process:960
    throw err;
    ^

Error: Command failed: dotnet "C:\Users\[...]\nswag\bin/binaries/Net60/dotnet-nswag.dll"

I run the following command, and the error makes me think it is not able to understand the /runtime parameter, which is actually fine as per documentation, and again... it worked in the past.

call npm install -g nswag
call nswag run generate.Service.nswag /runtime:Net60

Some things I tried, to execute same command but forcing to install a previous version of nswag (because I see new version applied quite recently) but this didn't work either. I tried with all the versions from like last year:

enter image description here

Another solution I tried is to remove this "wrong parameter", and I get this error now:

System.InvalidOperationException: The specified runtime in the document (NetCore21) differs from the current process runtime (Net70). Change the runtime with the '/runtime:NetCore21' parameter or run the file with the correct command line binary.

So i'm not sure what else I could try, I tried even the preview version which is not released yet and that also has the same issue. I see this problem comes and goes in the last 4 years, so probably somebody has a solution.

Thanks.

1 Answer 1

1

Ok, so i'm not sure if I got the solution, or there is an upgrade in NSWAG side.

The solution I found is to go to the folder mentioned in the issue, i.e.: "C:\Users[...]\nswag*.*"

After that, run again the command line and passed without issues, whitout making any change on my configuration files.

3
  • I got the same issue. I updated NSwagStudio to 14.0.0-preview8 version because it added support of .Net8. After update it seems standart nswag run *** /runtime:Net80 command stopped working with the same error as yours (Unrecognised arguments are present: [/runtime:Net80]). Even if I set runtime as Net60 it is still not working even tho it was working before an update. Could you clarify what you mean by "The solution I found is to go to the folder mentioned in the issue, i.e.: "C:\Users[...]\nswag*.*""? Where should I go to this folder? In console using cd command? It doesn't work for me...
    – Rudean
    Commented Dec 22, 2023 at 11:54
  • 1
    Looks like I truncated my message by mistake, I don't remember the solution, but barely remember it's either 1) open the folder to ensure your user has access to this folder (or at least throws the typical "grant permission" message)... or more likely 2) Delet the nswag folder and all of its content, and then after re-running, it will be downloaded all again, and no issues will be found. I think the later is the one I did.
    – Yogurtu
    Commented Dec 26, 2023 at 15:35
  • @Rudean Did you get it worked? I am facing same problem, recently upgraded to .Net8 and Nswag with 14.0.2 Commented Jan 20 at 3:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.