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
- EnhanceIO als SSD Cache Lösung für CentOS 7 installieren und konfigurieren
- VMWare: promiscuous mode bei Centos Host zulassen
- VPS mit 10GB RAM, 500GB HD für 30.50€/Jahr bei Greenvaluehost
- Hacksummit: virtuelle Konferenz 1.12.-4.12.
- Windows 8/Windows 8.1: das bessere Windows 7
- Connect: kostenloses Visual Studio, neue .net Versionen, Open Source
- Visual Studio 2013 Update 4 Final verfügbar
Meistbesucht in letzter Zeit
- Batch-Konvertierung mit HandBrake: alle Videodateien in einem Ordner und Unterordnern konvertieren - 5.190 Besuche
- Private Build in TFS 2012 sowie Private Drop Location - 2.941 Besuche
- Windows 8.1 Update ISO Offline Download und Installation - 2.896 Besuche
- Nook HD+ auf Android 4.4 Kitkat - 1.969 Besuche
- Bitmap Speicherverteilung bei nicht - alignter Breite in C# - 1.108 Besuche
- Programmierertugenden: Faulheit, Ungeduld, Selbstüberschätzung - 898 Besuche
- Schnell und günstig zur eigenen OwnCloud - 883 Besuche
- Schlechte Fremdwährungs-Umrechnungskurse bei Paypal umgehen - 600 Besuche
- Keine Verbindungen mehr möglich auf Tiger VNC Server auf Centos 7: Exit Code 2 - 435 Besuche
- Skype Video mit mehreren Personen auf Mobilgeräten: nur Audio - 261 Besuche
- Nie wieder seine Passwörter vergessen bei
- Impressum bei
- Schnell und günstig zur eigenen OwnCloud bei
- Hacksummit: virtuelle Konferenz 1.12.-4.12. bei
- Keine Verbindungen mehr möglich auf Tiger VNC Server auf Centos 7: Exit Code 2 bei
- Acer Iconia W500: Windows 8 installieren bei
- Windows 8.1 Update ISO Offline Download und Installation bei
- 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