Why is Visual Studio always rebuilding some projects?

By , last updated September 27, 2019

Visual Studio or VS is my weapon of choice.

But sometimes, it’s stupidity can’t be expressed with words…

The problem

Sometimes, Visual Studio will always rebuild projects, even though they have recently been built and there are no changes. If you build, and then run the project will build. If you haven’t disabled the “projects out of date”-dialog, it will pop up and ask you to rebuild.

Within VS, it will match a set of rules to figure out if a project is up to date or not.

Here is how to find out what rules are causing a project to always build.

This applies to both C# and C++ projects.

How to identify the problem.

The simplest way to discover this problem, and probably the most annoying about this is this popup box when running the project (unless you’ve disabled this dialog).

Project out of date popup Visual Studio

Another clue is output text. Regardless how many times you build the project, it’s never up to date.

1>------ Build started: Project: always-build, Configuration: Debug Win32 ------
1>  always-build.vcxproj -> R:code-samplesvisual-studio-always-buildingDebugalways-build.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

The first dialog will only show when “prompt to build” is selected.

Build and run options visual studio

How to fix the problem.

Open devenv.exe.config as Administrator. Default path for VS2013 is C:Program Files (x86)Microsoft Visual Studio 12.0Common7IDEdevenv.exe.config.

Add this section to the configuration file.

    <add name="CPS" value="Verbose" />

About here:

denenv exe config visual studio

Restart VisualStudio.

Download and run DebugView from Microsoft (https://technet.microsoft.com/en-us/library/bb896647.aspx).

Build the project.

In DebugView, you’ll see many lines of diagnostics information. One line in particular is the interesting one, that’s the line with not up to date because. If you can’t find that line, select the top line and hit Ctrl-F to open the search dialog, and search for not up.

debugview diagnostics lines

In this case, it’s because it’s missing a file referenced in the solution, [9300] Project 'R:code-samplesvisual-studio-always-buildingalways-build.vcxproj' not up to date because build input 'R:CODE-SAMPLESVISUAL-STUDIO-ALWAYS-BUILDINGNON-EXISTING-HEADER.HPP' is missing.

Remove that file from the solution, and try to rebuild.

When you get this text from the output window, you’re successful.

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

Just don’t forget to revert / delete the diagnostics settings in devenv.exe.config

The project and code from this post is available at GitHub.