Visual Studio 2008 keeps rebuilding [duplicate]
Asked Answered
D

1

5

Possible Duplicate:
Visual Studio keeps building everything

Visual Studio 2008 keeps rebuilding the entire project as if every implementation file was modified. This happens even if no files were modified. Hit build button twice in row, and the entire projects gets rebuild twice. This doesn't happens on another box. The OS is Windows Vista.

This is very annoying. What could cause such a behavior?

It is a C++ project.

Dormeuse answered 17/3, 2011 at 21:58 Comment(5)
What language are you compiling? With C#, it builds the projects each time you build.Scottiescottish
It sounds like you asked for the project to be built, and it built. It sounds like your actual question is: "Why does VS rebuild every project in the solution when nothing has changed since last rebuild?" Is this correct?Dufresne
@p.campbell. Yes, it keeps recompiling all object files. Always.Dormeuse
Have you tried to perform a full clean?Parmer
it always rebuilds the entire project on every build, as far as I know.Lulita
C
5

Some ideas to try...

As @David Paxson said in the comments, with some languauges (e.g. C#, VB) all the projects will appear to be "built", but the compiler will skip through the ones that don't need to be built much more quickly, even though they are still listed in the output. So it may simply appear to be rebuilding everything. Also, with C#, Visual Studio sometimes runs the project several times in a row, and sometimes it will decide for no obvious reason that it needs to "rebuild" the projects, but this only usually takes a few seconds extra unless you have hundreds of projects.

Restart Visual Studio (or even reboot the PC entirely).

Do a "Rebuild All" of the entire solution to clean out any old cached information and ensure all the output files are up to date.

If you use source control, then even better is to check in all of your changes, then delete your old source code folder (or safer, rename it somewhere out of the way until you know you don't need it) and force-get all the latest source code from source control again. This means you have a totally clean starting point (a clean or rebuild-all doesn't quite clean everything away, unfortunately). I do this every 2-4 weeks to keep everything running smoothly and totally in sync with the Source Control code.

If anything modifies the datestamps of any files in your build, then this could trigger a "need" to rebuild everything. Check that your system clock is set correctly, that there aren't any datestamps of source files set to times "in the future", and there are no applications running that could possibly "touch" any of your source files.

Check this option: Tools->Options > Projects and Solutions > Build and Run : "Only build startup projects and dependencies on Run". If it is unchecked, then VS will try to rebuild all projects every time, rather than only the dependencies of the startup project. If you have a large solution with a bunch of mostly unrelated projects in it, this is a very helpful option to set.

If there are projects that you don't need to build every time, then use the Configuration Manager to disable building of those projects in your current build (or create a "Debug Fast Build" configuration so you can switch quickly between a full rebuild and a partial build). Or move projects that don't need to be built often into a separate "libraries" solution and reference/link the output files (obj or dll) form your application's Solution, so the libraries only need to be rebuilt if you edit their code.

Lastly, make sure you're doing a "Build" and not a "Rebuild" :-)

Cleotildeclepe answered 17/3, 2011 at 22:32 Comment(2)
I checked everything and still not sure what is wrong. I used Visual Studio for many projects and never encountered such a strange behavior. I marked the answer as accepted anyway, since it mentions many other things which could cause unnecessary rebuilding.Dormeuse
As Jason states, take careful note of the system clocks on both computers. I had this problem once, and finally solved it when I realized one computer read 11:18 AM while the other one read 11:18 PM. When compiling on one box to the next, you want to make sure the times between the two computers are as close to the same as possible.Icarus

© 2022 - 2024 — McMap. All rights reserved.