C++ Visual Studio:项目不是最新的“因为指定了“AlwaysCreate”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6054066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 19:24:45  来源:igfitidea点击:

Visual Studio: project is not up to date "because "AlwaysCreate" was specified"?

c++visual-studiovisual-studio-2010visual-studio-2015msbuild

提问by Hertzel Guinness

I've migrated a solution from VS2008 to VS2010 (SP1).
Now one of my project never finds peace in being up-to-date. Every build have the following output:

我已经将一个解决方案从 VS2008 迁移到 VS2010 (SP1)。
现在,我的一个项目永远不会在更新中找到安宁。每个构建都有以下输出:

1>------ Build started: Project: PROJ_NAME, Configuration: Release Win32 ------
1>Build started 19/05/2011 7:59:27 AM.
1>InitializeBuildStatus:
1>  Creating "Release\PROJ_NAME.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  All outputs are up-to-date.
1>  All outputs are up-to-date.
1>Lib:
1>  All outputs are up-to-date.
1>  PROJ_NAME.vcxproj -> C:\projFolder.PROJ_NAME.lib
1>FinalizeBuildStatus:
1>  Deleting file "Release\PROJ_NAME.unsuccessfulbuild".
1>  Touching "Release\PROJ_NAME.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.09
========== Build: 1 succeeded, 0 failed, 5 up-to-date, 0 skipped ==========

Any ideas?

有任何想法吗?

回答by Bo Persson

I had a similar problem when one of the include files listed in the project didn't actually exist. I had deleted the file, but forgot to remove it from the project.

当项目中列出的包含文件之一实际上不存在时,我遇到了类似的问题。我已经删除了该文件,但忘记将其从项目中删除。

The dependency checker then believes the project is not up to date, but the builder finds nothing to build.

然后依赖项检查器认为该项目不是最新的,但构建器没有发现任何要构建的东西。

回答by Bzzt

I had two projects that contained the same file. When the second project built, it compiled the file again, changing the 'touch' datetime. That in turn set the 'AlwaysCreate' flag for the first project.

我有两个包含相同文件的项目。当第二个项目构建时,它再次编译文件,更改“触摸”日期时间。这反过来为第一个项目设置了“AlwaysCreate”标志。

I found this out by turning on 'CPS' in my "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config" file, as in the xml snippet below. With that activated you can use the DebugView tool to get messages from VS2010 that state WHY it is rebuilding your project. Why those messages don't go into the build log is beyond me, but anyway there it is.

我通过打开“C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config”文件中的“CPS”发现了这一点,如下面的 xml 片段所示。激活后,您可以使用 DebugView 工具从 VS2010 获取消息,说明为什么要重建您的项目。为什么这些消息没有进入构建日志是我无法理解的,但无论如何它在那里。

Add this:

添加这个:

<system.diagnostics>
  <switches>
    <add name="CPS" value="4" />
  </switches>
</system.diagnostics>

To here:

到这里:

<?xml version ="1.0"?>
<configuration>
    <configSections>
        <section name="msbuildToolsets" type="Microsoft.Build.BuildEngine.ToolsetConfigurationSection, Microsoft.Build.Engine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </configSections>
    <system.diagnostics>
      <switches>
        <add name="CPS" value="4" />
      </switches>
    </system.diagnostics>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319" />

回答by Oded

According to thisthread on MSDN:

根据MSDN上的这个线程:

In my case in VS10 it was due to having missing (but non-complied .h files, thus no additional error to identify) in project folders.

A quick check that all project files can open in editor fixed this problem.

在我的 VS10 中,这是由于项目文件夹中缺少(但未编译的 .h 文件,因此没有其他错误可识别)。

快速检查所有项目文件都可以在编辑器中打开解决了这个问题。

回答by Jacek

You must check also other files than .h. In my project Readme.txt was missed.

您还必须检查 .h 以外的其他文件。在我的项目 Readme.txt 中被遗漏了。

回答by boatcoder

I moved a solution to a new folder, and every time I built a new version or tried to debug, it would want to claim that all the projects that made up the solution were out of date, even though it had just built them.

我将一个解决方案移到一个新文件夹,每次我构建一个新版本或尝试调试时,它都会想声称组成该解决方案的所有项目都已过时,即使它刚刚构建它们。

I searched all the .vcxproj files, used DebugView with CPS=4 (see @Bzzt's answer above) and discovered it was looking for the header files in their OLD location. Since the solution was moved, not copied, those files did not exist.

我搜索了所有 .vcxproj 文件,使用了 CPS=4 的 DebugView(参见上面@Bzzt 的回答),发现它正在寻找旧位置中的头文件。由于解决方案是移动的,而不是复制的,因此这些文件不存在。

What finally solved it for me was cleaning the solution and doing one rebuild. After that the "AlwaysCreate" was no longer causing it the "build" all the sub projects. You have to clean each configuration (debug and release) separately, but once it has been rebuilt from the clean state, all is well.

最终为我解决的是清理解决方案并进行一次重建。之后,“AlwaysCreate”不再导致它“构建”所有子项目。您必须分别清理每个配置(调试和发布),但是一旦从清理状态重建,一切都很好。

In my case it didn't actually do any building, but MSBuild or whatever decided things were out of date, was using some cached filepath that no longer existed. The Clean and Rebuild replaced that cache and then it built like expected

就我而言,它实际上并没有进行任何构建,但是 MSBuild 或任何已过时的决定性事物使用了一些不再存在的缓存文件路径。Clean and Rebuild 替换了那个缓存,然后它像预期的那样构建

回答by zizopen

I got the same issue.

我遇到了同样的问题。

Root-cause: incorrect build version of VS (32bit and 64bit)

根本原因:不正确的 VS 构建版本(32 位和 64 位)

Solution: Switch mode Debug/Release from 32 bit to 64 bit or reverse

解决方案:切换模式 Debug/Release 从 32 位到 64 位或反向

http://postimg.org/image/3jurey1qr/

http://postimg.org/image/3jurey1qr/

回答by Vince

In Visual Studio 2010, I eliminated spurious rebuilds of a many-project solution by leaving Multiprocessor Compilation (/MP) unset (pity!). Previously, I had it enabled. Find the flag here: Common Properties > C/C++ > General > Multi-processor Compilation. Also, I noticed that I was able to eliminate individual projects' spurious rebuilds by rebuilding each project individually; then a build of each showed that each was up-to-date.

在 Visual Studio 2010 中,我通过不设置多处理器编译 (/MP) 来消除多项目解决方案的虚假重建(可惜!)。以前,我启用了它。在此处找到标志:Common Properties > C/C++ > General > Multi-processor Compilation。此外,我注意到我能够通过单独重建每个项目来消除单个项目的虚假重建;然后每个的构建显示每个都是最新的。

回答by Matthew Lowe

To get this to work, I simply renamed my existing output directory, in order to recreate all intermediate files (after trying all of the above accepted answers).

为了让它起作用,我只是重命名了我现有的输出目录,以便重新创建所有中间文件(在尝试了上述所有接受的答案之后)。

I've had success in the past using DebugView in VS2010 to find files to delete, but today that approach did not work. I could not find ANY reference to the missing header files, found using DebugView, within any of my code or project files XML. I also retrieved the outdated files from TFS to try with them both present and absent on my machine.

过去我在 VS2010 中使用 DebugView 找到要删除的文件取得了成功,但今天这种方法不起作用。在我的任何代码或项目文件 XML 中,我找不到任何对使用 DebugView 找到的丢失头文件的引用。我还从 TFS 中检索了过时的文件,以尝试在我的机器上存在和不存在它们。

I then used GREP to search my entire solution directory, and the only results were in binary files: the old code files' *.obj, the project file's *.pdb, and vc100.idb. I don't know how these files get modified/replaced during build and rebuild, so I'm not sure if a previous reference in one of those files was responsible for claiming the old header files were missing.

然后我使用 GREP 搜索我的整个解决方案目录,唯一的结果是二进制文件:旧代码文件的 *.obj、项目文件的 *.pdb 和 vc100.idb。我不知道在构建和重建过程中这些文件是如何被修改/替换的,所以我不确定其中一个文件中的先前引用是否负责声称旧的头文件丢失。

Hope this helps someone down the road, and thanks for the above info that got me started!

希望这可以帮助有人在路上,并感谢上述信息让我开始!

回答by Shane Gannon

For command line msbuild.exe builds you can use /verbosity:detailed and search the output for

对于命令行 msbuild.exe 构建,您可以使用 /verbosity:detailed 并搜索输出

  • "will be compiled as" to find compilations
  • "Source compilation required" to find links
  • “将被编译为”以查找汇编
  • “需要源代码编译”来查找链接

Note: Output can be piped to file by using msbuild.exe /verbosity:detailed > output.txt

注意:可以使用msbuild.exe /verbosity:detailed > output.txt将输出通过管道传输到文件

e.g.

例如

code.cpp will be compiled as C:\path\to\header.h was modified at 18/02/2016 15:58:31.
Outputs for C:\path\to\code.cpp:

回答by GilesDMiddleton

You may also find this happens after a windows update see this: Up to date projects compiled again because of TZRE.DLL date stamp is in the future after a windows update

您也可能会在 Windows 更新后发现这种情况,请参阅:最新项目再次编译,因为 TZRE.DLL 日期戳是在 Windows 更新后的未来

The solution is to wait till that time, and the problem will magically vanish. I just had the same problem, My TZRES.DLL file is 17/07/2018 19:54, the time now is 17/07/2018 15:15

解决办法是等到那个时候,问题就会神奇地消失。我刚遇到同样的问题,我的 TZRES.DLL 文件是 17/07/2018 19:54,现在是 17/07/2018 15:15