via API Explorer spawning endless dotnet.exe processes
See original GitHub issueI have previously used NSwag Studio on a Core project via “Web API or ASP.NET Core via Reflection” successfully. Today I started on a new Web API and thought I’d try out “ASP.NET Core via API Explorer”, and at first all worked well.
I created the standard startup project (“dotnet new webapi”) and created an NSwag Studio project for that and set it up to generate CSharp Client classes, which it did. Then I changed something, and it stopped working. I believe the only thing I changed, was the name of the controller class (from ValuesController to MyValuesController) and NSwag Studio would no longer complete the processing of the project - it would just hang.
I tried triggering it via NSwag.MSBuild, as I’ve done in my previous project, and the same happened there: dotnet build never completed. It just output:
Executing file 'eeapi.nswag'...
And then after a long while:
System.InvalidOperationException: Process dotnet timed out.
at NSwag.Commands.SwaggerGeneration.AspNetCore.Exe.RunAsync(String executable, IReadOnlyList`1 args, IConsoleHost console, Nullable`1 timeout)
at NSwag.Commands.SwaggerGeneration.AspNetCore.ProjectMetadata.GetProjectMetadata(String file, String buildExtensionsDir, String framework, String configuration, String runtime, Boolean noBuild, IConsoleHost console) in C:\projects\nswag\src\NSwag.Commands\Commands\SwaggerGeneration\AspNetCore\ProjectMetadata.cs:line 136
at NSwag.Commands.SwaggerGeneration.AspNetCore.AspNetCoreToSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\SwaggerGeneration\AspNetCore\AspNetCoreToSwaggerCommand.cs:line 65
at NSwag.Commands.NSwagDocumentBase.GenerateSwaggerDocumentAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocumentBase.cs:line 268
at NSwag.Commands.NSwagDocument.ExecuteAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocument.cs:line 81
at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 77
at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 31
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.Process(String[] args, Object input)
But still, it doesn’t complete.
What I found, was that both of these ways of executing the project, spawns a lot of dotnet.exe processes, in the region of around 10-20 per second. It peaked at nearly 1200 dotnet.exe processes when I managed to kill them off.
If I Ctrl+C out of the build, I get back to my command prompt, but warnings start to pop up, about every five seconds (path masked):
[PATH_TO_PROJECT][PROJECT_NAME].csproj(26,9): warning MSB4220: Waiting for the currently executing task “Exec” to cancel.
Any ideas what’s going on?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
When using AspNetCoreToSwaggerGenerator via MSBuild you need to set NoBuild to True so that you dont end up in an endless build loop…
Sorry for the late reply (vacation time 😉).
You are right: I was specifying the .csproj and had NoBuild set to false. Changing this to true fixed the problem.
Selecting the DLL instead of the .csproj didn’t work. I haven’t read up on this feature, so possibly I’m missing some other setting, but it seems it still tries to interpret it as a .csproj file:[ProjectPath]\bin\Debug\netcoreapp2.1[ProjectName].dll(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.Edit: Doh! My bad, I’d but the DLL reference in the wrong input in NSwag Studio.
I got it to work, so I’m happy 😃
Just one follow up question: When would NoBuild be set to false? You say this is related to using NSwag.MSBuild, but I see the same behavior when running from NSwag Studio.