0

I am using Visual Studio 2022 (Version 17.6.5), the nuget package for NSwag.ApiDescription.Client (version 13.19.0).

When try to Rebuild, its is getting this error:

The command ""x\packages_rep\nswag.msbuild\13.0.5\build\../tools/Win/NSwag.exe" openapi2csclient /className:ServiceClient /namespace:MyService /input:x\swagger.json /output:obj\swaggerClient.cs " exited with code -1.

Where x above is my local web project path.

M_Idrees
  • 2,080
  • 2
  • 23
  • 53

1 Answers1

0

I found the root cause in my case was the whitespaces in the path to the project.

We need to fix in the file:

{MyProject}\packages_rep\nswag.apidescription.client\13.0.5\build\NSwag.ApiDescription.Client.targets

You will find line # 21 similar to this:

 <Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(Options)</Command>

To make swagger work with whitespaces, change this line by adding double quotes around the path:

 <Command>%(Command) /input:"%(FullPath)" /output:"%(OutputPath)" %(Options)</Command>

My project works fine after this fix.

M_Idrees
  • 2,080
  • 2
  • 23
  • 53