When Visual Studio keeps on rebuilding projects that did not change it can be a quite time-consuming pleasure. Many of you might have solutions of a similar or even greater size than mine (with currently 40+ projects) and hitting the build button twice (and waiting twice) one cannot help but wonder why the second build takes just as long as the first one.
After taking some time investigating the project settings of those unchanged projects, I came up with some tips on how to avoid/minimize the rebuild-effort.
There are some pitfalls to avoid which cause an unchanged project to rebuild. Most of them are not obvious, and making things even more difficult: VS seems to be of little help when you try to circle in the problem. Also, I used VS 2008, outdated though it may be, for the IDE was not my choice in here.
Copy local (Reference)
Specific Version (Reference)
The worst option seems to be if you copy files from within the same solution that other projects are using to their path via copy local. VS notices the frequent update and keeps on rebuilding. Use a Post-Build-Event instead to copy the files if really needed (see below).
If you are missing a .. when wanting to output all the files to the same directory or have any similar problem with your output path, this also can cause rebuilds.
They have a nice option to only run „When the build updates the project output“. This typically makes a lot of sense, since most Post-Build-Events will do something with a (newly) changed file, like copy it somewhere else. If the file has not changed, only very few actions would make sense.
Circular References are a bad thing and should be avoided in general (no possibility to build „from scratch“). Also, they most often are avoided by a decent design and since they mostly only cause problems: don’t use then.
Typically, you want to avoid this, at least when you want to build care-free. If you have a lot of problems with versioning, you might want to keep this option set. In most cases, you will not have a problem with switching this option off even if you do need specific versions, since you typically know specifically which specific version you specified and everything should com out as expected.
Keep your dependencies in a sensible order. You should include necessary dependencies and avoid those that are not necessary among your own projects. If you don’t, this can mess up your build order, causing you to have to rebuild multiple times till you have a version that even compiles error-free. Also, include as few dependencies as possible. If C is dependent on B is dependent on A you should have exactly that dependence and not mark C to also be dependent on A. This is inferred automatically and makes later changes easier.
More Tips on hunting Problematic Projects
One easy thing is to force compiler warnings, e. g. by using
#warning Project was rebuilt!!
to notify you whenever a project rebuilds. This warning is only written to the build output when the project is actually compiled (or at least that sourcefile).
One more thing is to corner down the project that causes a rebuild. If you watch closely, it is often the case that when you build a specific project and its dependencies, the build is very fast, there is hardly any output, and no rebuild was done. The same projects though can be rebuilt if you build another project that is dependent on those. So hunt for a minimal subset of projects which to examine.
Lastly, I have noticed that when I choose „Build Solution“ several projects are always rebuilt, though when I choose to build the main project (that is dependent directly or indirectly on every single other project) it does not rebuild anything the second run. Comparing the build output of the 2 runs with WinMerge I found no difference in project build order, only in the fact that the „Build Solution“ rebuilds some projects.
Also note that the „Only build startup projects and dependencies on Run.“ option you can find under Tools->Options->Projects and Solutions->Build and Run can speed up your debugging a lot (starting your projects e. g. with F5) with builds after code changes when debugging being often a lot faster.
Using all those ideas, you can speed up your build effort considerably, especially since I am strongly missing the „Rebuild Project“ option that I grew accustomed to in VS6 (I think?). Especially the quick „does it still compile?“ check once in a while to figure out how close to valid code the last few lines one wrote are will become again what it should be: quick and effortless.
Einen Kommentar schreiben
Meistbesucht in letzter Zeit
- Kostenloser Online-Speicher: Synchronisation, WebDAV, Größe, Komfort - 36.408 Besuche
- LG Optimus 7 II P715 auf Android 4.4.4 Kitkat bringen - und beschleunigen - 10.468 Besuche
- Greg's XML Editor (minor fixes) - 7.236 Besuche
- Ganzjährig günstig durch Deutschland mit der Deutschen Bahn - 7.170 Besuche
- Ubuntu 14.04 LTS neu aufsetzen - 6.384 Besuche
- Sicherheitsupdate für Microsoft .NET Framework 4 (KB2478663) benötigt länger - 5.589 Besuche
- Squid Proxy unter Ubuntu 14.04 LTS Linux einrichten als HTTP Proxy - 5.237 Besuche
- Animierter Bitmap-Hintergrund für 2D Spiele in XNA - 5.055 Besuche
- Windows 10 Upgrade Lizenzbeschränkungen und -restriktionen - 4.188 Besuche
- Windows Ordnerzugriff: Zugriff verweigert - 3.826 Besuche
- Weihnachtsgeschenk 2: 6 Monate kostenlos Pluralsight Kurse bei
- Squid Proxy unter Ubuntu 14.04 LTS Linux einrichten als HTTP Proxy bei
- Wenn das Windows Update versagt bei
- Windows 10 Update ausblenden bei
- Windows 8.1 Update Problem: Die Einrichtung der Updates konnte nicht abgeschlossen werden bei
- Skype Video mit mehreren Personen auf Mobilgeräten: nur Audio bei
- Windows VMs direkt bei Microsoft beziehen bei
- Januar 2016
- Dezember 2015
- November 2015
- September 2015
- August 2015
- Juni 2015
- März 2015
- Januar 2015
- Dezember 2014
- November 2014
- Oktober 2014
- September 2014
- Mai 2014
- April 2014
- März 2014
- Januar 2014
- Dezember 2013
- Oktober 2013
- Juli 2013
- Juni 2013
- Mai 2013
- März 2013
- Januar 2013
- Dezember 2012
- Oktober 2012
- September 2012
- August 2012
- Juli 2012
- Juni 2012
- Mai 2012
- April 2012
- März 2012
- Februar 2012
- Januar 2012
- November 2011
- Juli 2011
- Juni 2011
- Mai 2011
- April 2011
- März 2011
- Februar 2011
- Januar 2011
- Dezember 2010
- November 2010