20

I've a C++ project that I'm currently porting from VS2008 to VS2010. When I build the project, Visual Studio 2010 reports the build as successful but if I then press F5 to start the debugger I'm told that the project is not up to date. If I ignore this warning, I can continue debugging ok, but if I press ok, the whole project (many hundreds of source files), gets rebuilt from scratch. The output contains the following;

1>------ Build started: Project: SCCW-VC2010, Configuration: Debug Win32 ------
1>Build started 15/11/2010 14:47:40.
1>InitializeBuildStatus:
1>  Creating "Debug\SCCW-VC2010.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>Midl:
1>  All outputs are up-to-date.
1>ClCompile:
1>  tinedit.cpp
1>  _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1>  Automatically linking with sfl504d.lib
1>  Automatically linking with ot1104d.lib
1>c:\program files\rogue wave\stingray studio 10.4\include\toolkit\sectndlg.h(134): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>  Automatically linking with og1204d.lib
1>  Automatically linking with RWUXThemeD10.lib
1>  profile.cpp
1>  ZOffsetDialog.cpp

Half an hour later, once the build is finished, the debugger starts. My guess is that the message

Creating "Debug\SCCW-VC2010.unsuccessfulbuild" because "AlwaysCreate" was specified.

is part of the problem, but I cant tie this to a project setting. I've found some help on google, but nothing that has worked thus far. Anyone else had this problem and know of a fix?

Edit: As per Jalf's suggestion in the comments below, I have created a new projected, imported all my files into that project, and the new project has the same problems. Specifically, I copied over all the following groups;

<ClCompile Include="..\MyDir\MyFile.cpp"/>
<ClInclude Include="..\MyDir\MyFile.h" />
<None Include="res\MyFile.ico" />  (and all similar resources)
<Library Include="..\MyDir\MyFile.lib" />

Edit2: After going through all the header includes I eventually found 3 that did not exist. Removing them and doing a rebuild all on the original project seems to have fixed the problem. Some of the blog posts that mention this problem refer to it as a bug, and two days of lost time later, I tend to agree. Thanks for the answers and comments provided.

Edit3: And one day later the problem is back! Making any edit to any file in the project once again causes a full rebuild. As per John Dibling's answer, the project does include some static libraries, including Stingray. I'm ditching VS2010 and moving back to VS2008, as I have deadlines. For related information, see the following links;

Visual Studio 2010 always thinks project is out of date, but nothing has changed

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/38c08137-3bb0-4143-b97f-72d077646318

Link

Final Edit The release of VS2010 SP1 has solved this problem, and builds are now fast and efficient.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
SmacL
  • 22,555
  • 12
  • 95
  • 149
  • is it an option to simply recreate the solution + projects? – jalf Nov 15 '10 at 15:12
  • @jalf, it is an option, but a time consuming one to do from the IDE as there are a lot of files in different locations. I could hack it by making a blank vxcproj and cutting and pasting my files over, but could well end up taking the problem with me. – SmacL Nov 15 '10 at 15:17
  • I don't think you would take the problem with you if you did that. Upgrading projects from one version of VS to another always causes it to set all sorts of strange settings that typically aren't necessary (and sometimes, as in your case, even introduces errors). If you could just create a blank project and then re-add all the files, I suspect it'd work fine. – jalf Nov 15 '10 at 23:55
  • @jalf, created a new project and imported all the files as per my edit above, but no improvement. Worth a try though. And the new project is much smaller than the imported version and compiles somewhat quicker. – SmacL Nov 16 '10 at 15:24
  • shame it didn't fix it. But good to hear there's some improvement at least. It really does seem like projects get cluttered up badly with each version upgrade. I've noticed similar differences before. – jalf Nov 16 '10 at 17:49
  • @Shane MacLaughlin: Out of curiosity, do you have Visual Studio 2010 with the SP1 applied? I am not saying applying it will fix the problem. Rather, I am curious if it manifests itself even with SP1 applied. – wilx May 19 '11 at 06:20
  • @wilx, I moved back to VS2008 as a result of this, but plan on trying again with VS2010 SP1. Will keep you posted. – SmacL Jul 21 '11 at 16:02

11 Answers11

14
  1. See in output window what file is rebuild

  2. Go to menu Tools->Options, then navigate to Project and Solutions->Build and Run. Change option MSBuild Project build output verbosity to:

    Diagnostic
    
  3. Build, got long log

  4. Find file (from 1) in log, read diagnostic. You may found for example header name which has date in future or absent.

E. van Putten
  • 615
  • 7
  • 17
xen
  • 141
  • 1
  • 2
  • 1
    This is the best advice, a generic solution to quickly find out the cause of the problem. Just set diagnostics on and build the first Project that you think is building unnecessarily, and BINGO - the first line of the diagnostics told me. I had two projects with files I had deleted and I had one project with the AlwaysCopy attribute set on a file. – GilesDMiddleton Jul 23 '15 at 13:42
  • 2
    @GilesDMiddleton I'm using Visual Studio 2015 and the first line of the diagnostic file doesn't tell me anything useful. I actually cannot find in the diagnostic file what triggers the rebuild (it's many thousands of lines long and I can't read all of it). What strings should I search for? I tried the common-sense ones such as "rebuild" but got nothing useful. – adigostin Dec 12 '16 at 17:15
  • "You may found a header which has date in future" did you came from the future? Saved a lot of time! – navossoc Feb 23 '22 at 14:04
9

I've had this problem many times and it was always frustrating. I'll tell you what the problem was in my case, but first I have to ask you:

  • Did you do a rebuild-all before you tried running the first time, or just a rebuild?
  • Once you do a rebuild all, does it ask you yet again to rebuild if you've made no changes?

The problem in my case was somewhat complex. I had custom build rules that copies binaries for Stingray from their source directory (where they lived) to a directory in my build tree. The binaries were marked as a dependancy, so that they were copied before each build in case they changed.

The dependancy checked looked at the timestamps of these files to see when they were changed. If the blah.lib had a mod date of last December in it's source directory, then when it was copied it would have the same mod date. The dependancy checked would note that "hey this file's pretty old, we have to rebuild it," and then it would ask if I wanted to do a full rebuild.

For a while I got by by just saying "No," but eventually I fixed the problem by changing the custom build rule to write a new text file after it did the file copy. That would make the new text file the dependancy, and not the blah.lib file, and it made the compiler happy.

John Dibling
  • 99,718
  • 31
  • 186
  • 324
  • yup did a rebuild all and still get the problem which I suspect is very similar to yours. The following MSDN social link contains similar conclusions to your own. http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/38c08137-3bb0-4143-b97f-72d077646318 – SmacL Nov 15 '10 at 15:21
5

I had the same problem on both converted and from-scratch projects. I got a hint from a MS page about missing files. I checked my project and found that it referenced a file that did not exist. Replaced it with the correct file, and the problem went away.

GTAE86
  • 1,780
  • 3
  • 29
  • 39
  • FWIW, I had a really tough series of these problems when our build environment was upgraded to VS 2012 - lots of cases where it was not obvious what was going on. I followed the instructions here - http://blogs.msdn.com/b/andrewarnottms/archive/2012/06/07/enable-c-and-javascript-project-system-tracing.aspx as well as at the link mentioned at the top of that article to use a second instance of Visual Studio to debug the build process in a first instance. Worked like a charm. – GTAE86 Mar 19 '14 at 13:58
4

I know this is a very, very old post but for the benefit of all who still have this problem I decided to post my input. because "AlwaysCreate" was specified has nothing to do with project being rebuilt.

IT is the other way around. If you or Visual Studio decides to rebuild all, this causes creation of the "*.unsuccessfulbuild" file.

Some other issue (usually header that does not exist) will cause rebuild all leading to displaying because "AlwaysCreate" was specified.

"AlwaysCreate" is a part of Visual Studio build environment settings and is part of the Microsoft.CppBuild.targets XML file. It contains following line: Touch AlwaysCreate="true" Files="$(LastBuildUnsuccessful)"/

It this is set to true, ".unsuccessfulbuild" file will always be created regardless of the build being successful or not. If this is changed to false, ".unsuccessfulbuild is not created. If true the *.unsuccessfulbuild file is created as empty for the duration of the build process and then delete if build is successful. I am not sure why this file is created; even if the build has errors, the file is empty but not deleted as in case of the successful build.

Possibly the existence of this file has some meaning known only to VS build environment. If you want to play with this setting, deleting Touch key from

JohnCz
  • 1,613
  • 1
  • 9
  • 9
  • I believe that this file is created because there are some possible failures in the build process that cannot be detected by source/target file timestamp alone. For example, there may be pre/post events that run but which produce no discernible target files. If they fail, and the build stops, or the build crashes mysteriously, the .unsuccessful build file will be there next time and the build system knows to try again. – Wheezil Jan 27 '15 at 15:19
2

The MSDN docs imply that this property is specific to deployment projects.

findstr /si AlwaysCreate on your VS2010 project files should show you the culprit(s) if you can't track it down in the GUI.

Steve Townsend
  • 53,498
  • 9
  • 91
  • 140
  • The url is expired and I suppse the correct command would be `findstr /si AlwatsCreate *.vcxproj` ... anyway this failed to find the source of the problem in my case. – sorin Jul 27 '13 at 14:23
  • 1
    Updated the URL for VS2010-specific form since it's gone from VS2012 – Steve Townsend Jul 27 '13 at 15:45
  • This did not solve the same problem which I have with vs2012, see here my case http://stackoverflow.com/questions/17900716/how-to-solve-the-infamouns-alwayscreate-true-rebuild-issue-with-msbuild – sorin Jul 27 '13 at 17:44
0

The link is in one of the comments here, but it is easy to miss, so I repost the basic steps here from this link: MSDN Article

Actually I found this link on my own, and only later realized that this was already mentioned here.

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 your VisualStudioInstallFolder\Common7\IDE\devenv.exe.config file.  Note this will be in %ProgramFiles(x86)% on 64-bit Windows.
3. Open a text editor with admin privileges.
4. Add this snippet to your devenv.exe.config file just below the <configSections /> block:
    For Visual Studio 2012 and below...
    <system.diagnostics>
    <switches><add name="CPS" value="4" /></switches>
    </system.diagnostics>
    For Visual Studio 2013
    <system.diagnostics>
    <switches><add name="CPS" value="Verbose" /></switches>
    </system.diagnostics>
5. Save the text file.

I use Visual Studio 2010 + SP1 and both of the XML snippets seem to work.

Now you need a tool that can display windows DebugOutput like DebugView.

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.
Devolus
  • 21,661
  • 13
  • 66
  • 113
0

If there are no "legitimate" reasons for the constant rebuilding (e.g. references to missing header files), try deleting the solution's .sdf file (when the solution is closed, of course) and rebuilding. That just worked for me.

ulatekh
  • 1,311
  • 1
  • 14
  • 19
0

Solution modifying devenv.exe.config + use of DebugView worked for me (vs2010).

DebugView lists the missing file for you.

NickCoder
  • 1,504
  • 2
  • 23
  • 35
0

In my case it seemed to help to build the deployment project(s). I have set them not to build when I hit F7 but manually. Some people suggest creating a new solution + projects but that's not a very good option when the projects have a lot of manual tweaking and custom build rules.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
Kari
  • 1
0

Decided to revisit this with the release version of SP1. I recreated a new project from scratch, which came out at 81k compared to the upgraded older project of 1.4mb which was carrying all sorts of junk with it. Initially, I came across the same problem, but managed to resolve it as follows;

  • Changed pre-compiled headers to Create (/Yc)
  • Compiled one source file
  • Changed pre-compiled headers to Use (/Yu)
  • Did a full rebuild

Next problem I noticed was that any resource addition was causing a recompile of all files containing including resource.h This was fixed using advice from the following Microsoft connect thread and manually adding the following lines to my project;

<ItemGroup>
    <ClNoDependencies Include="Resource.h" />
</ItemGroup>
SmacL
  • 22,555
  • 12
  • 95
  • 149
-1

If file date is abnormal, that case is occurred. VS Compiler must recompile all files with future date. -- Example --

Current date : June 30, 2015
File date : July 1, 2015
The file is always compiled during today.

It is not related with AlwaysCreate directive.

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41