Visual Studio stuck at "build must be stopped before the solution can be closed"

vb.netVisual Studio

vb.net Problem Overview


When the Visual Basic compiler (Vbc.exe) crashes, Visual Studio fails to detect this and becomes stuck in an inoperable state. The "Build" menu appears as it would if the solution were building, but the Cancel Build (Ctrl+Break) menu item has no effect. Trying to close the application or the solution gives the error:

> The build must be stopped before the solution can be closed.

I can't find any way to remedy this short of terminating the devenv.exe process and restarting Visual Studio completely. Is there anything quicker and less severe?

(Microsoft claims to have fixed this bug in 2005, but I'm experiencing it with VS2008.)

vb.net Solutions


Solution 1 - vb.net

I'd look for msbuild process(es) to kill before devenv. And make sure vbc really has gone too.

And as the comments say, try using msbuild yourself.

Seeing as I've got a Nice Answer badge from this, I feel I should emphasise my comment below: In all the cases where this has happened to me there have been no msbuild or vbc processes to kill. If anyone gave or gives me a +1 because they did find a stuck msbuild or vbc process, please comment that this was the case too.

Solution 2 - vb.net

You can use a shortcut ctrl+break in VS, this should cancel build process.

Solution 3 - vb.net

I see this error in Visual Studio 2013 Professional as well. I terminated devenv.exe through Task Manager.

Solution 4 - vb.net

For Visual Studio 2015 or greater, in Menubar, under Build option, there is "cancel" option. This will stop the build.

Solution 5 - vb.net

S O L V E D it!

Had this problem in VS2017 prof vs15.9.16. When performing a build, build starts to compile but never finishes. Build-menu items are grayed out except for 'cancel'. And cancel does not work. Using a different compiler worked! 'Kill process' was the only way to kill the build.

Stripping the program to its bare minimum showed the real problem. There where referenced DLL's that hung the build. Compiling the DLL's and re-referencing them solved the problem.

Solution 6 - vb.net

sometime this problem also arise in VS2015. Following the same process (kill process) would work here too.

Solution 7 - vb.net

I had this problem arise in VS2015. You can specifically kill the MSBuild.exe process without shutting down Visual Studio.

Solution 8 - vb.net

I had this today whilst using VS2019 (16.4.2). I my case I started a publish - it was a database project - and changed my mind so cancelled the publish using Ctrl+Break. The build showed as completed successfully, and the publish did not start. Publish was greyed out and I could not exit VS because of this error. I had no msbuild or vbc processes running. My solution was to kill the devenv process.

Solution 9 - vb.net

Still happens in VS 2022. .Net host process gets stuck while building project with version conflict dependencies. Resolving those conflicts helps and build proceeds, but again, the question why dotnet process is getting stuck on it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionduozmoView Question on Stackoverflow
Solution 1 - vb.netMark HurdView Answer on Stackoverflow
Solution 2 - vb.netGrengasView Answer on Stackoverflow
Solution 3 - vb.netMike UpjohnView Answer on Stackoverflow
Solution 4 - vb.netJay PatelView Answer on Stackoverflow
Solution 5 - vb.netTonView Answer on Stackoverflow
Solution 6 - vb.netAbhay DixitView Answer on Stackoverflow
Solution 7 - vb.netRyanView Answer on Stackoverflow
Solution 8 - vb.netNathan ScottView Answer on Stackoverflow
Solution 9 - vb.netSergioView Answer on Stackoverflow