Search code examples
visual-studioconditional-compilation

Visual Studio - How to refrain from compiling all project files every build?


Each time I build my Visual C++ solution in Visual Studio 2010, the entire project (not the entire solution) recompiles.

There must be a flag or configuration somewhere to make VS compile only the changed files + depending files. Where is it?

UPDATES:

  • I set "Yes (/Gm)" to My project's configuration properties\C/C++\Code Generation\Enable Minimal Rebuild. It still compiles all the project's files upon F7.

Solution

  • If in addition you get the a message similar to:

    Creating ".\Release\SomeLib.unsuccessfulbuild" because "AlwaysCreate" was specified.

    when building, the reason might be that one of your projects refers to a header file which does not exist on disk (see here and here).

    The first link also includes a small C# script to check for this situation. To fix, simply remove the reference to the non-existing header files from your project.

    Update

    It might be possible that you have your precompiled-headers setting on 'Create'. To fix, right-click your project in the solution browser and select: properties -> C/C++ -> Precompiled Headers -> Precompiled Header. Change the setting from Create to Use or Not Using Precompiled Headers.