AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

Build process hangs on beginning #99

Closed dominikjeske closed 5 years ago

dominikjeske commented 5 years ago

On my test solution (.NET Standard 2.0 for class generator and .NET Core 2.0 for using generator) build process is beginning and nothing is happening, there is no messages in Debug/Build window. I have to cancel the build which takes 3-5 seconds and after this another attempt to build will succeed. It happens even when no class have code generation attribute on it – it looks like build is hanging on the beginning. After some testings it looks like most of the time build hangs after rebuild or clean/build, when I only build solution it is not happening (at least it looks like this after couple tests)

I’m using VS 2017 15.8.4.

AArnott commented 5 years ago

We may be able to take action on this if you add details like a process dump, or callstacks perhaps

ugumba commented 5 years ago

I think I see the same issue. I built a small solution (attached) with the sample code. Rebuilding the full solution seems to work.

However, if I make a dummy change in "MyClass" (add and remove a character) and build that project (F6, Shift+F6, or right-click project + Build), it always hangs. Cancelling and restarting that build always works, until I make a code change again.

When enabling diagnostic MSBuild output, it appears to hang after package restore, but before MSBuild even starts. (The "Feeds used:" lines is the last thing I see in Build output.)

VS2017 15.8.7. Disabled Resharper.

CodeGenHang.zip

ugumba commented 5 years ago

@AArnott, further experimentation indicates that the normal build (e.g. triggered by F6) conflicts with Live code analysis, if both happen at the same time - probably a deadlock/race condition.

Both hang if my code change is saved automatically by starting a build (F6), thus also triggering Live code analysis. When I cancel the build, code analysis eventually completes correctly.

It doesn't hang if I save (Ctrl+S), wait a couple of seconds (until the Live code analysis background task is done, as indicated by the background tasks icon in the lower left), then build (F6).

ugumba commented 5 years ago

I can no longer reproduce this issue with VS 2017 15.9.1. @bigdnf, if you can verify, this issue could be closed.

dominikjeske commented 5 years ago

After one month I also don't see this behaviour so I'm closing this issue