Issue building Swagger during build-time on non-Windows platform
See original GitHub issueIn the wiki you describe how to wire up the generation to occur during build, which is of great value. However, when I run this on a Mac, I see that it’s specifically calling a tool from the Win
folder, that’s an .exe
. This fails on a Mac with the following error output at build-time.
Task "Exec" Environment Variables passed to tool: ASPNETCORE_ENVIRONMENT=Development "/Users/bradygaster/.nuget/packages/nswag.msbuild/13.3.0/build/../tools/Win/NSwag.exe" aspnetcore2openapi /assembly:/Users/bradygaster/source/Weather/bin/Debug/netcoreapp3.1/Weather.dll /output:swagger.json /var/folders/yd/yx7g3rbn1rn9n5x_pr65m0980000gn/T/tmp4180e802dbe54195a9ca0ca149253efb.exec.cmd: line 2: /Users/bradygaster/.nuget/packages/nswag.msbuild/13.3.0/build/../tools/Win/NSwag.exe: cannot execute binary file 1:7>/Users/bradygaster/source/Weather/Weather.csproj(15,5): error MSB3073: The command ""/Users/bradygaster/.nuget/packages/nswag.msbuild/13.3.0/build/../tools/Win/NSwag.exe" aspnetcore2openapi /assembly:/Users/bradygaster/source/Weather/bin/Debug/netcoreapp3.1/Weather.dll /output:swagger.json" exited with code 126. Done executing task "Exec" -- FAILED. 1:7>Done building target "NSwag" in project "Weather.csproj" -- FAILED. 1:7>Done Building Project "/Users/bradygaster/source/Weather/Weather.csproj" (default targets) -- FAILED.
Is there an upcoming fix for this? It seems limiting that this is only available on Windows, when .NET Core and MSBuild are available on on other platforms.
Would love to sync up on some ideas I have for using this, but they’d require it work on non-Windows as well, given the use-case.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
You’re probably using $(NSwagExe) in your csproj which is the full .net binary, for .NET Core you need to use eg. $(NSwagExe_Core31)
see https://github.com/RicoSuter/NSwag/wiki/NSwag.MSBuild
The main problem without Newtonsoft is that System.Text.Json does not expose metadat/reflection api, see https://github.com/RicoSuter/NSwag/issues/2243
Sure I’m working from home and often available… 🙂