Visual Studio: Stop Building That Project!
10 Jul 2006I regularly work on a Visual Studio solution at work with 40+ individual projects in it. Irritatingly, many of them have begun to suffer from the “always rebuilt” problems that recent versions of Visual Studio (2002-2005) have shown. I decided to try and fix these things today and so here are a list of things to try that have helped me:
My project always builds, starting with MIDL
A few potential causes here:
-
If your IDL file imports another file (even in a #defined out section) that does not exist, this will cause VS to continually build the IDL file resulting in all dependent files and projects being built. Make sure included files exist.
-
If your IDL file imports files from another directory which import other files this can sometimes cause the dependency checker to get lost. Try adding your project directory to the include path.
-
For some reason, generating a type library (.tlb) file can be the cause of this. If you don’t need the type library, disable generation in the project properties (or .idl file properties). This is the one that solved the problem for me.
My project always links
I have had a number of projects that link every time even though nothing had changed, a combination of the following tips seems to solve the problems:
-
You can specify wildcards (e.g.
*.lib
) in the additional dependencies box for the linker. This seems to result in this being re-evaluated at every build. Point at the specific libs you need and you’ll solve this one. -
Using forward slashes in the “Linker\Advanced\Import Library” option causes projects to need to re-link regularly. I have changed all of mine to standard backslashes and this seems to solve that problem! This tip may cover other directory paths as well - best thing is to ensure that all project settings paths use backslahes.
-
PDB file with a different name to the build output - if your .exe builds as myapp.exe and the PDB is myoldappname.pdb then the project will relink all the time, update the PDB filename to match the .exe!
Knowledge Base/Google Groups Articles
The following knowledge base articles, blog and Google Groups posts were vaguely useful in sorting these problems out: