Updated on September 22, 2015
My Visual Studio solution won’t build although it should. What can I do?
Visual Studio is undoubtedly the best development environment you could get your hands on – but sometimes it can drives you crazy. Espacially in these cases where you know that a project should build but it doesn’t no matter how hard you try. What you can do is trying these tricks and tips. Maybe one of them helps.
Clean and Rebuild
The first thing you should try is to click on Build ➔ Clean solution and Build ➔ Rebuild solution. In 30% of the cases it already solves your problems.
Restart Visual Studio
May sound simple and stupid but believe me, the next 30% of errors will go away after a simple restart.
Restore all NuGet packages
Sometimes your NuGet packages get lost, corrupted or need to be resored. To fix that you can open the NuGet Package Manager for each Project by right clicking it’s References folder and select Manage NuGet packages. Here you can restore the missing packages.
Another smart way to archive and automatic restore whenever you build a solution is enabling the automatic NuGet package restore option that you can find by right clicking your solution folder in Visual Studio.
Regenerate the .suo file
Another thing to try, is to close VS and delete the hidden
.suo file that is next to the
.sln file in your solution’s folder. Don’t worry. It will be re-generated the next time you save or build. Note that deleting the
.suo file will reset the startup project(s) of the solution.
Make sure, that all projects build
Right click on your solution in the solution explorer, go to Properties and select the Configuration Manager. Check if the checkboxes under Build are checked or not. If any or all of them are unchecked, then check them and try building again. If they are all checked you can also try to uncheck them, apply, check them again and apply again. Sounds weird, but sometimes it helps.