Troubleshoot build process for visual studio solution

If you have a solution with multiple projects to manage, you will most probably face issues where some projects have to rebuild just every single time you build the solution. Another issue I see happen from time to time is long build time for entire solution (On clean-all or build server).

Project always being rebuilt

There are multiple reasons for a project to be marked for rebuild. If you want to stop the project from rebuilding every single time, you have to identify what is marked as a modification, forcing the project to rebuild.
To do so, go to

Tools –> Options -> Projects and solutions -> Build and run

Under this window, change MSBuild project output and log verbose to Diagnostic.

Now that we’ve enabled the detailed output, hit a Ctl+shift+b, to rebuild the solution.

Go to the output window and you should see the reason for your project to be rebuild.

1>Project ‘SomeProject.Web’ is not up to date. Input file ‘C:\dev\SomeProject\SomeProject.Web\bin\SomeProject.Web.XML’ is modified after output file ”.

In that case, the project is built because it detected a change in my project XML documentation output file.

Just do this for every project in your solution until you build and see 0 succeeded 0 Failed

========== Build: 0 succeeded, 0 failed, 25 up-to-date, 0 skipped ==========

 

Solution slow to rebuild after clean up

One factor for slow build of your project is IOPS. When you compile a solution, there’s a lot of io operations going on to copy your files and assemblies all around. This is in part due to the fact that any references added to your projects are marked as Copy Local. This means that every time you build your project, the compile will make sure to write that reference to the bin folder of your project.

When you perform a clean solution, these references have to be copied all over again, and this will considerably slow down your build process.

To work around this, you usually want to have most of your reference from your startup project as copy local, and leave the other references as Copy Local false. You usually can’t have all of your references as copy local false, as some of the libraries really require to be present in the bin folder, but you can set all of them to false, test your app, and enable copy local on libraries that fails one at the time.

Submit a Comment

Your email address will not be published. Required fields are marked *

Share This