다음을 통해 공유


‘AlwaysCreate’ forces project to be re-built

Issue

Have you lost time because Visual Studio always thought that a project was out-of-date? Recently had a customer who faced this issue. He migrated his project from VS2008 to VS2010. Rebuilt the whole project and tried to run. He saw this message box pop up…

image

 

If you click ‘Cancel’ and do a build, then in the output window you’ll see this…

1>------ Build started: Project: TestAlwaysCreateIssue, Configuration: Debug Win32 ------
1>Build started 3/12/2013 6:24:04 AM.
1>InitializeBuildStatus:
1> Creating "Debug\TestAlwaysCreateIssue.unsuccessfulbuild" because "AlwaysCreate" was specified.

This message is quite confusing and doesn’t give a hint as to what actually is wrong and why the project is being re-built! Visual Studio internally decides the project is out-of-date and hence decides to build again before execution.

You won’t lose time if the project is a small one but think about a solution having numerous projects a build/relink is going to take forever to complete (I’ve faced this personally for some reason this rebuild issue vanished after sometime).

Cause

So what causes this false rebuild?

To figure why Visual Studio decides that project is out-of-date you’ll have to enable project system logging in visual studio. See following blog on how to enable this feature in Visual Studio.

blogs.msdn.com/b/vsproject/archive/2009/07/21/enable-c-project-system-logging.aspx, for convenience I’ll paste in here relevant part from the blog…

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

To enable logging in the Visual C++ project system you just have to add a snippet to a .config file:

  1. Since it can be difficult to recover from a damaged devenv.exe.config file, consider copying the file to devenv.exe.config.original before modifying it so you have a backup copy you can revert to if things go awry.
  2. Open a text editor with admin privileges.
  3. Open your VisualStudioInstallFolder\Common7\IDE\devenv.exe.config file. Note this will be in %ProgramFiles(x86)% on 64-bit Windows.
  4. Add this snippet to your devenv.exe.config file just below the <configSections /> block:
    1. For Visual Studio 2012 and below...
      <system.diagnostics>
      <switches><add name="CPS" value="4" /></switches>
      </system.diagnostics >
    2. For Visual Studio 2013<system.diagnostics>
      <switches><add name="CPS" value="Verbose" /></switches>
      </system.diagnostics>
  5. Save the text file.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Above block of xml will enable diagnostic logging of build activities in Visual Studio. To view the diagnostic logs from Visual Studio you should either have a debugger hooked onto visual studio or you should have DebugView. DebugView is a tool that helps viewing application output which the application does via OutputDebugString API.

Output in DebugView should look like as follows once you enable project system logging in Visual Studio. Screenshot…

image001_20130304-224824-224807_1

Now follow these steps…

  1. Start DebugView 
  2. Rebuild
  3. Build
  4. In DebugView window search for the string ‘missing’ or 'not up to date', better still to save the DebugView log entries and open it in notepad and then search.
  5. In this case we found the following message…
    [2968] Project 'C:\Projects\TestAlwaysCreateIssue\TestAlwaysCreateIssue\TestAlwaysCreateIssue.vcxproj' not up to date because build input 'C:\PROJECTS\TESTALWAYSCREATEISSUE\TESTALWAYSCREATEISSUE\NONEXISTENT.H' is missing.
  6. Copied above line of text from DebugView. The message clearly says why visual studio thinks the project is not up-to-date! The reason being nonexistent.h file is missing from disk.
  7. The file nonexistent.h file was deleted from disk on purpose to reproduce this issue.

Its quite easy to reproduce the issue, just add a .h file from disk to the project and then rename/delete this file, rebuild and build. You’ll see that Visual Studio says the project is not up-to-date. See below screenshot…

image 

Resolution

Resolution is quite easy, just remove the non-existent file from the project. 

Summary

Yes to get to the root cause we had to do some magic but that’s how it is for now. This behavior is there in VS2012 as well. So hope this saves some of your valuable time. If you know of a better or straight forward way to solve this do let us know. I’d like to thank Steve Horne (Sr. EE) at Microsoft who troubleshot a similar case long back, found all this information out of that case. Thanks Steve!

Please remember to undo the changes made to devenv.exe.config.

Comments

  • Anonymous
    November 19, 2013
    Most of the time the 'AlwaysCreate' is set when there are references in the project to files that don't exist. Header files, files referenced to as resources, readme.txt etc. Missing .cpp files should cause compile errors so no problem there. Here is yet another error I discovered. It has to do with COM-projects with separate proxy/stub projects built in x64. The intermediate directory in x64 for proxy/stub is set to the same directory as the COM-project, causing both projects to be rebuilt and all the other projects depending on them. This has been lingering ever since VS2010 just  as the Register Output-flag doesn't work for x64. Microsoft, how about fixing it? VS2010, VS2012 & VS2013. STILL SAME ERROR.

  • Anonymous
    December 11, 2013
    I had this in Visual Studio 2013, where that config file does not seem to exist anymore. I've found that when opening the Solution Explorer's project tree, the files which were not found won't have the little triangle in front of the filename (with which you normally can see a list of symbols in that file).

  • Anonymous
    December 12, 2013
    @Ruud van Gaal I do see the config file in the following folder... "C:Program Files (x86)Microsoft Visual Studio 12.0Common7IDEdevenv.exe.config" Are you looking under C:Program Files. If you use %PROGRAMFILES% that's the path which explorer will resolve the environment var on a 64 bit OS. Probably I should remove %PROGRAMFILES% from the text. From your comment I guess you found the root cause, if not, apart from what's already in the article, further help needed let me know. Nibu Thomas Microsoft Support

  • Anonymous
    January 16, 2014
    i have a solution where the "Project is out of date message" is appearing when i try to start the Debugger. i have no idea why vs thinks, the project is out of date. The message appears even after a "rebuild all" with no Errors or warnings during the build. i was thus trying to use the method you suggest in order to find the reason why vs keeps thinking that particular Project is out of date. i did edit the config file (and restartet visual Studio afterwards), and i did download and run debugview. i did then do a "rebuild all", and lots of Messages where written to the debug view window. Next, i cleared debug views Display, and hit "run in Debugger". Now, not a single message appeard in debug view, but the "Project is out of date" message still appeared. Any suggestions what i'm doing wrong or how i can find out why it thinks the Project is out of date? WM_THX -thomas woelfer

  • Anonymous
    January 16, 2014
    Hi Thomas, What version of Visual Studio? After a rebuild, do a build 'build'. Check debug view again for missing file message. Nibu

  • Anonymous
    January 16, 2014
    hi Nibu. This is vs 2013 rtm. i did do a "rebuiild solution", started debugview, and then did a "build solution". during that build. the "Special" Project got build. However, there is no useful Information in debugview. all i get are the following 2 lines  (repeatedly for ~270 times, so there are actually 546 lines in debug view:): [3700] The build property "BuildingInsideVisualStudio" with value "true" is being overridden with the value "true" by the global property provider "Microsoft.VisualStudio.ProjectSystem.Build.CommonBuildPropertiesProvider". [3700] CPS Warning: 0 : That's it. nothing else is displayed. Maybe i need some other settings in the config file for 2013? WM_THX -thomas woelfer

  • Anonymous
    January 16, 2014
    I'll create a repro on VS2013 and check this out. I haven't tested the steps given in the blog for VS2013. I'll get back to you, maybe by next week.

  • Anonymous
    January 26, 2014
    hi Nibu. Any news yet ? WM_THX -thomas woelfer

  • Anonymous
    January 26, 2014
    Sorry Thomas, didn't look into this yet, too busy with work. You should hear from me soon.

  • Anonymous
    January 26, 2014
    Thomas, Looks like there were some changes in the configuration file schema or values. With the configuration given in this blog I didn't see missing file warnings so you are right there. I referred the documentation and made some changes. This is how the changed diagnostics section in the config file should look like... <pre> <system.diagnostics> <switches> <add name="CPS" value="Verbose" /> </switches> </system.diagnostics> </pre> The change looks to be with the value given for CPS. 'Verbose' works for me. Created a repro project in VS2013, I have a missing file in the project so for me debugview shows following output... <pre> 00000266 53.95375824 [4308] CPS Verbose: 0 : 00000267 53.95384216 [4308] Project 'C:Userssomuserdocumentsvisual studio 2013ProjectsLeakerLeakerLeaker.vcxproj' not up to date because build input 'C:USERSNTHOMASDOCUMENTSVISUAL STUDIO 2013PROJECTSLEAKERLEAKERLEAKER - COPY.H' is missing. </pre> I my project indeed I have a file named: LEAKER - COPY.H which is missing from hard disk. Please check if this change helps you? If so please let us know, I'll have to modify this blog entry for VS2013. -Nibu -Microsoft Support

  • Anonymous
    January 29, 2014
    hi Nibu, thank you very much, that did it. (at least in my ie11, there's a "pre" key in your previous instruction that does not belong there, but without it, the logging works fine.) i was able to detect what made vs 2013 think the project was allways out of date (a missing header file). just as a note to anybody else trying to figure out stuff like this: it helps a lot, when in debugView one is searching for the string "not up to date "... WM_THXALOT -thomas woelfer

  • Anonymous
    January 29, 2014
    Cool! I'll update blog as well. PS: Sorry for the <pre> tag. :) Intention was to make it look neat.

  • Anonymous
    May 13, 2014
    After getting annoyed by the issue for long, I finally decided to investigate what was behind the apparently unnecessary prompt from VS2012 to build some project even just after finishing building. In my case, the cause turned out to be two projects in the solution putting their intermediate files (obj files) in the same folder. As discussed at the following link and links listed there, when multiple projects put their objs in the same folder, rebuild can result in the deletion of the objs of earlier built project. stackoverflow.com/.../difference-between-rebuild-and-clean-build-in-visual-studio-2008 Another thing: Even in VS2012, I had to change CPS value to "Verbose" instead of "4" to get useful debug info in DebugView.

  • Anonymous
    May 14, 2014
    Thanks Venkat for sharing your solution.

  • Anonymous
    July 28, 2014
    Same as Venkat, I had to use "Verbose" instead of "4" even with Visual Studio 2012.  Please update the article.   Thanks.

  • Anonymous
    August 24, 2014
    The comment has been removed

  • Anonymous
    January 03, 2015
    I found an easier fix (also works on vs2013: I changed the option in "Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity" from Minimal to Diagnostic. Source: stackoverflow.com/.../vs2010-always-thinks-project-is-out-of-date-but-nothing-has-changed

  • Anonymous
    January 04, 2015
    If this works (I haven't verified yet) then its indeed easy. Thank you Christiaan for sharing this.

  • Anonymous
    May 30, 2015
    The comment has been removed