VS2010 rebuilds C++ project because of modified irrelevant files

别来无恙 提交于 2019-12-21 04:22:32

问题


As all of us already know VS2010 has got an major upgrade of its build system, which is based on MSBuild.
According to MS representatives (see comments in Visual Studio 2010 always rebuild project after hibernation/restart of computer) MSBuild now injects itself into other tools (like C++ compilers, linkers, etc.) to find out the dependencies of a target.
One of the drawbacks of such approach is that now your project may be forcedly rebuilt because of modifications in irrelevant files :(
In my case it is C:\PROGRAMDATA\NVIDIA CORPORATION\DRS\NVDRSDB0.BIN, which is periodically changed by NVIDIA update service (Windows 7 32-bit).

I've discovered that by turning VS2010 options "MSBuild project build output verbosity" and "MSBuild project build log file verbosity" to "Diagnostic".
After that I was able to see the cause of the issue in the Build Output Window:

Task "CL" (TaskId:55)
  Read Tracking Logs: (TaskId:55)
    ..\..\temp\Release\Editor\cl.read.1.tlog (TaskId:55)
  Outputs for E:\USERS\A.USER.ORG\DEVEL\EDITOR\STDAFX.CPP: (TaskId:55)
E:\USERS\A.USER.ORG\DEVEL\TEMP\RELEASE\EDITOR\STDAFX.OBJ (TaskId:55)
  C:\PROGRAMDATA\NVIDIA CORPORATION\DRS\NVDRSDB0.BIN was modified at 23-Feb-12 12:08:20. (TaskId:55)
 stdafx.cpp will be compiled. (TaskId:55)
...
 Tracking command: (TaskId:55)
 C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\Tracker.exe ... stdafx.cpp /clr:nostdlib  (TaskId:55)
 stdafx.cpp (TaskId:55)
Done executing task "CL". (TaskId:55)

One of the workarounds is to add the irrelevant files to C++ ignore list:

<ItemGroup>
  <ClNoDependencies Include="NVDRSDB0.BIN" />
  <ClNoDependencies Include="C:\PROGRAMDATA\NVIDIA CORPORATION\DRS\NVDRSDB0.BIN" />
</ItemGroup>

Unfortunately this doesn't help :( And I didn't yet check how this trick works on other PCs, where such files don't exist.

So the question remains: is anybody aware of the working solution for this problem?

I didn't try installing SP1 for VS2010 - according to enthusiast this step doesn't help either.
Disabling NVIDIA update service may probably help (it will stop updating the file), but there are or may be other software which cannot be disabled this way (antivirus, other utilities, etc.).
See also related questions:

  • VS2010 always thinks project is out of date but nothing has changed (the similar issue seems to be caused by a missing source file)

回答1:


I have this same problem, except that the "modified" file in my case is

C:\PROGRAMDATA\SOPHOS\SOPHOS ANTI-VIRUS\CONFIG\CONFIG.BOPS

Microsoft has admitted there is a bug (which will be fixed in the next release) and suggested workarounds

http://connect.microsoft.com/VisualStudio/feedback/details/715572/unexpected-rebuild-of-projects

http://connect.microsoft.com/VisualStudio/feedback/details/649139/vs2010-does-complete-rebuild-based-on-completely-unrelated-file

but none of these has worked for me so far. I'm still trying to muck with my

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.targets

file and add something like the following to my property sheets

<ItemGroup>
  <ClNoDependencies Include="C:\PROGRAMDATA\SOPHOS\SOPHOS ANTI-VIRUS\CONFIG\CONFIG.BOPS"/>
</ItemGroup>

but I have had no luck so far. Perhaps you can get this work-around to work for you? (Let me know if it does!)




回答2:


We had the same problem with the Sophos CONFIG.BOPS file. We have a large team and our solution has 80+ projects, so the workaround described by others was unappealing to us. I took an approach that has worked beautifully. Some may say that it's a total hack, which I'll admit it is, but it's incredibly simple and it works for now until Microsoft fixes this.

I wrote a tiny desktop tray app in C# that monitors the CONFIG.BOPS file, and whenever the timestamp changes, it sets it back to an old date using File.SetLastWriteTime without modifying the file contents. The app must be run as administrator on Windows 7, but that's fine for us as our staff all has admin rights to their PCs. We don't have the NVDRSDB0.BIN problem, but I suspect it could work for that case as well.




回答3:


I was able to get rid of this problem by adding C:\PROGRAMDATA\NVIDIA CORPORATION\DRS\ to my user property sheet VC++ Directories/Exclude Directories.

To edit this file, open View->Property Manager it will be under every project/configuration.

If you don't want to do this system wide you can create a new property sheet and add it just to the projects you need to set it for. You can multi-select all the projects you need this set for in the Property Manager and right click->Add New property Sheet.



来源:https://stackoverflow.com/questions/9412023/vs2010-rebuilds-c-project-because-of-modified-irrelevant-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!