Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue building Swagger during build-time on non-Windows platform #2749

Closed
bradygaster opened this issue Mar 26, 2020 · 5 comments
Closed

Issue building Swagger during build-time on non-Windows platform #2749

bradygaster opened this issue Mar 26, 2020 · 5 comments

Comments

@bradygaster
Copy link

In 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.

@RicoSuter
Copy link
Owner

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

@bradygaster
Copy link
Author

Thanks @RicoSuter - saw that shortly after posting the issue. Will make sure this works as expected with some changes and close if so. Thanks so much.

Any opportunities for a Teams sync next week?

@bradygaster
Copy link
Author

@RicoSuter - tried this and out-of-the-box with a 3.1 Web App that doesn't have a Newtonsoft.JSON dependency, it doesn't work. Error below. Will peruse the docs and figure out what to do to resolve, but "as little as possible" would be optimal given the use-case scenario I'm thinking of.

System.InvalidOperationException: No service for type 'NSwag.Generation.IOpenApiDocumentGenerator' has been registered.

@bradygaster
Copy link
Author

Never mind - got it working. I was under the impression that there'd be no need for the inclusion of nswag.aspnetcore, but once I added it and wired up the middleware it works. Thanks for the help. Again, let me know if you have time to sync up soon, looking forward to talking about some new ideas here.

@RicoSuter
Copy link
Owner

The main problem without Newtonsoft is that System.Text.Json does not expose metadat/reflection api, see #2243

Sure I’m working from home and often available... 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants