Occasionally, builds within Visual Studio fail with an error similar to:
Warning (active) CS8785 Generator 'OpenApiCSharpGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'TypeInitializationException'
Note: This particular issue pertains to the TypeInitializationException; if you are getting a different exception, that is a different issue.
Underlying cause is still TBD.
Workaround: When this happens, the VBCSCompiler.exe stays running (otherwise it is a temporary process); use TaskManager to kill the VBCSCompiler.exe process. Visual Studio will be able to compile correctly again.