RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.62k stars 1.22k forks source link

nswag stuck, noBuild: true #3119

Open nrpriore opened 3 years ago

nrpriore commented 3 years ago

Oddly starting a week ago or so - intermittently, nswag will fail with:

  Executing file 'nswag.nswag' with variables 'Configuration=Debug'...
  Launcher directory: C:\Windows\ServiceProfiles\NetworkService\.nuget\packages\nswag.msbuild\13.2.2\tools\NetCore31
  System.InvalidOperationException: Process dotnet timed out.
     at NSwag.Commands.Generation.AspNetCore.Exe.RunAsync(String executable, IReadOnlyList`1 args, IConsoleHost console, Nullable`1 timeout) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\Exe.cs:line 70
     at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\AspNetCoreToOpenApiCommand.cs:line 215
     at NSwag.Commands.NSwagDocumentBase.GenerateSwaggerDocumentAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocumentBase.cs:line 279
     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 86
     at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 32
     at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
     at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
     at NConsole.CommandLineProcessor.Process(String[] args, Object input)
     at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\projects\nswag\src\NSwag.Commands\NSwagCommandProcessor.cs:line 56

csproj file:

  <Target Name="NSwag" AfterTargets="Build">
    <Exec Command="$(NSwagExe_Core31) run nswag.nswag /variables:Configuration=$(Configuration)" />
  </Target>

nswag file snippet:

  "runtime": "NetCore31",
  "defaultVariables": "",
  "documentGenerator": {
    "aspNetCoreToOpenApi": {
      "project": "MyProject.csproj",
      "msBuildProjectExtensionsPath": null,
      "configuration": "$(Configuration)",
      "runtime": null,
      "targetFramework": "netcoreapp3.1",
      "noBuild": true,
      ...

At first, I double checked the value of noBuild & confirmed this was set to true, since I know this can cause an infinite loop. It indeed is and always has been set to true. It just sometimes works and sometimes times out & fails now. We've been using this successfully for months, but seemingly started recently.

Any idea what could be causing this?

cchulo commented 3 years ago

Did you ever find a solution for this? Timeout was updated to 5 min back around October in issue #3096 I believe, but I am also hitting that timeout.

cchulo commented 3 years ago

@RicoSuter What are the possible causes of timeouts? I noticed you increased the time to 5 minutes, and our program consistently times out every 5 minutes. In our case we are using MSBuild, and the command is aspnetcore2openapi, but otherwise results in same issue reported in this issue.

We are pointing at csproj, instead of assembly, and we have noBuild set to true. We are using 13.9.4, updating to 13.11.1 or downgrading makes no difference.

cchulo commented 3 years ago

we resolved it, we were missing [ApiController] Attribute, as soon as we added it to the controller, nswag doesn't hang anymore

RicoSuter commented 3 years ago

Hmm, I think i saw something similar in the past where the ASP.NET Core API Explorer goes into an infinite loop or something (ie not in the NSwag code but when NSwag tries to query the APIs)... maybe this is fixed in .NET 5?

jarrettv commented 2 years ago

Also having this issue with MSBuild and NetCore31 using aspNetCoreToOpenApi with csproj. Always hangs after it announces Duration: 00:00:03.0259005