question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

via API Explorer spawning endless dotnet.exe processes

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RicoSutercommented, Jul 27, 2018

When using AspNetCoreToSwaggerGenerator via MSBuild you need to set NoBuild to True so that you dont end up in an endless build loop…

1reaction
CRidgecommented, Jul 19, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does dotnet run launch 2 processes?
1 Answer 1 ... dotnet run is a development command that builds the project and queries the project for the actual command to...
Read more >
Something is spawning infinite instances of explorer.exe ...
I start Steam. Just starting Steam seems to cause this. After a few minutes, instances of explorer.exe will keep spawning until my machine ......
Read more >
NET Code Analysis For High CPU Usage
In this article, Toptal engineer Juan Pablo Scida analyzes a real scenario of high CPU usage of a web application. He covers all...
Read more >
The Dangers of Implementing Recurring Background Tasks In ...
Problem is, ASP.NET doesn't know about work done on a background thread spawned using a timer or similar mechanism. It only knows about...
Read more >
Process.Start Method (System.Diagnostics)
Starts a process resource by specifying the name of an application and a set of command line arguments. Start(String, String, String, SecureString, String)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found