-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSwag infinite loop with strange lengthening output #4404
Comments
First I tried using .NET Assembly to avoid the infinite loop. This was a mistake: it generated output successfully, over 3000 lines of it, but all 3000 lines appear to be garbage because it treated ControllerBase as a DTO (#1535). It seems that NSwagStudio running forever and NSwag-in-msbuild running forever were unrelated phenomena. NSwag-in-msbuild runs forever when the "noBuild" option is off. Why NSwagStudio does so remains unknown. By setting
To help debug this, I added a For me the issue was that NSwag calls
|
The problem is that NSwag generators internally run MSBuild, which builds the project that is currently building (like from VS or dotnet build) and is running a post-build action. Since we have an NSwag target project that runs as a PostBuildEvent, these internal MSBuilds get into an infinite recursion constantly building the same project (NSwag runs MSBuild, which runs NSwag, which runs MSBuild, and so on...). The problem is that the |
I also see a growing number of .NET processes being spawned (100% CPU), after upgrading to .NET8.0 and nswag 14.x - I fix it by setting |
I was able to use NSwag to generate a TypeScript wrapper on a fresh new C# project. However, the same settings don't work on our large commercial project. I set up the NuGet packages like this:
And if I generate code inside NSwagStudio, it apparently generates code forever.
Edit: Note: I am using the "ASP.NET Core via API Explorer | Project (Recommended)" mode in NSwagStudio, and NSwagStudio runs forever even if the
NoBuild
option is set, and even if none of the "Outputs" checkboxes are checked.So next I tried running NSwag from my web API's csproj file:
This project has a single nullability warning CS8602 when it is built, but NSwag compiles the project in a loop and the warning is repeated dozens of times. The following very long output is produced (project name and path redacted). Is there some way I can investigate the cause of the problem?
Here is the nswag.json file. (edited: to a shorter version that sthill has the problem)
If I fix the warning, the build stalls, the output is muted, and an exception is printed after several minutes:
The text was updated successfully, but these errors were encountered: