This one may be an edge case. I don't think it's a bug in NSwag yet I think it's the best place to discuss it.
Background
We have a .NET 8 project referencing two swagger files via the Visual Studio "Connected Services/Service References" feature, so the relevant part of .csproj looks like this:
We use the same exception class added to ApiExceptionNamespace manually, and we instruct NSwag to not generate ApiException via
/GenerateExceptionClasses:false added to each swagger file (see above).
Problem
When we dotnet build the project, for some reason, for the second client, /GenerateExceptionClasses:false is inserted twice:
It used to work fine with v13, but updating to v14 causes the second file generation to fail with:
NConsole.UnusedArgumentException: Unrecognised arguments are present: []
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 65
This is caused by /GenerateExceptionClasses:false being inserted twice for the second file's command during dotnet build, and if we remove it from the second file's <Options> in .csproj - it works (/GenerateExceptionClasses:false is still inserted automatically, but now we have it only once).
I believe it is caused by updating NConsole version in v14, but I can be wrong.
The root cause, probably, is this magical automatic addition of /GenerateExceptionClasses:false during dotnet build, but I validated this behavior was the same in .NET 7 and probably earlier, so decided to create the issue here.
This one may be an edge case. I don't think it's a bug in NSwag yet I think it's the best place to discuss it.
Background
We have a .NET 8 project referencing two swagger files via the Visual Studio "Connected Services/Service References" feature, so the relevant part of .csproj looks like this:
We use the same exception class added to ApiExceptionNamespace manually, and we instruct NSwag to not generate ApiException via
/GenerateExceptionClasses:false
added to each swagger file (see above).Problem
When we
dotnet build
the project, for some reason, for the second client,/GenerateExceptionClasses:false
is inserted twice:It used to work fine with v13, but updating to v14 causes the second file generation to fail with:
This is caused by
/GenerateExceptionClasses:false
being inserted twice for the second file's command duringdotnet build
, and if we remove it from the second file's<Options>
in.csproj
- it works (/GenerateExceptionClasses:false
is still inserted automatically, but now we have it only once).I believe it is caused by updating NConsole version in v14, but I can be wrong.
The root cause, probably, is this magical automatic addition of
/GenerateExceptionClasses:false
duringdotnet build
, but I validated this behavior was the same in .NET 7 and probably earlier, so decided to create the issue here.Thanks!