1.GetServiceProvider(AssemblyLoader assemblyLoader) in /_/src/NSwag.Commands/Commands/Generation/OpenApiGeneratorCommandBase.cs:line 313 1> at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunIsolatedAsync(AssemblyLoader assemblyLoader) in /_/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs:line 323 1> at NSwag.Commands.IsolatedCommandBase
1.IsolatedCommandAssemblyLoader.Run(String commandType, String commandData, String[] assemblyPaths, String[] referencePaths) in //src/NSwag.Commands/Commands/IsolatedCommandBase.cs:line 76
1> at NSwag.Commands.IsolatedCommandBase`1.RunIsolatedAsync(String configurationFile) in //src/NSwag.Commands/Commands/IsolatedCommandBase.cs:line 61
1> at NSwag.Commands.IsolatedSwaggerOutputCommandBase`1.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/IsolatedSwaggerOutputCommandBase.cs:line 51
1> at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs:line 98
1> at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
1> at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
1> at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in /_/src/NSwag.Commands/NSwagCommandProcessor.cs:line 61
1>C:\Users\timmb\source\repos\TestWebAPI\TestWebAPI\TestWebAPI.csproj(9,4): error MSB3073: The command "dotnet "C:\Users\timmb.nuget\packages\nswag.msbuild\13.20.0\buildTransitive../tools/Net60/dotnet-nswag.dll" aspnetcore2openapi /assembly:C:\Users\timmb\source\repos\TestWebAPI\TestWebAPI\bin\Debug\net6.0\TestWebAPI.dll /output:swagger.json" exited with code -1.
.Net 6.0 project - win api
include in csproj file :
Build project and swagger.json created.
In program.cs add:
var webApplicationOptions = new WebApplicationOptions() { ContentRootPath = AppContext.BaseDirectory, Args = args, ApplicationName = System.Diagnostics.Process.GetCurrentProcess().ProcessName }; var builder = WebApplication.CreateBuilder(webApplicationOptions);
rather than:
var builder = WebApplication.CreateBuilder(args);
and build fails to generate swagger.json. By process of elimination go to:
var webApplicationOptions = new WebApplicationOptions() { Args = args };
and the swagger.json will be generated when build.