C++ Visual Studio 项目已过期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14969138/
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
Visual Studio Project out of date
提问by user1795223
I've been trying to get Visual C++ working, but I'm getting this error when building every project: "This project is out of date" "Would you like to build it?" It fails to build every time.
我一直在尝试让 Visual C++ 正常工作,但是在构建每个项目时都出现此错误:“此项目已过时”“您要构建它吗?” 每次都无法构建。
When I rebuild, the build still fails, although in the logger I don't notice any error messages, which makes me think its not logging properly (I'm using a third party program to log).
当我重建时,构建仍然失败,尽管在记录器中我没有注意到任何错误消息,这让我认为它没有正确记录(我正在使用第三方程序来记录)。
I've followed some of the instructions here: http://blogs.msdn.com/b/vsproject/archive/2009/07/21/enable-c-project-system-logging.aspxand enabled logging.
我遵循了这里的一些说明:http: //blogs.msdn.com/b/vsproject/archive/2009/07/21/enable-c-project-system-logging.aspx并启用了日志记录。
I'm getting this error: project not up to date because "insert file name here".lastbuildstate is missing. Note that in actual visual studio, there is nothing logged. I was unable to find anything on this in google. It may be that I incorrectly enabled logging, but I feel that this is the error.
我收到此错误:项目不是最新的,因为“在此处插入文件名”.lastbuildstate 丢失。请注意,在实际的 Visual Studio 中,没有记录任何内容。我无法在谷歌中找到任何关于此的内容。可能是我错误地启用了日志记录,但我觉得这是错误。
回答by Colin Smith
What are "tlog" files?
什么是“tlog”文件?
"tlog" files are created by the "Tracker.exe" process which runs while you do a build, and records some information about the build.
“tlog”文件由“Tracker.exe”进程创建,该进程在您进行构建时运行,并记录有关构建的一些信息。
That information is used and updated the next time you start a build to help detect "out of date" files, and thus enable the build system to only build the bits that need to be rebuilt (rather than building everything again).
下次开始构建时会使用和更新该信息,以帮助检测“过时”文件,从而使构建系统仅构建需要重建的位(而不是重新构建所有内容)。
What causes the "out of date" problem?
什么原因导致“过时”问题?
The problem can be caused by incorrect or stale information in the *.tlog
files.
该问题可能是由*.tlog
文件中的不正确或陈旧信息引起的。
There are 3 main ways that can happen:
有3种主要方式可能发生:
1) You built a project on your hard disk, and then moved the directory to another location...the "tlog" files recorded the paths of the old location, yet because you moved the files, they are no longer there, thus you get "out of date".
1)您在硬盘上建立了一个项目,然后将目录移动到另一个位置……“tlog”文件记录了旧位置的路径,但是由于您移动了文件,它们不再存在,因此您得到“过时”。
2) Your "Project" has references to files (usually header files), which do not exist at the location specified. This might occur if you deleted a file from your source control system, but forgot to remove it from your project, or because you refer to header files of a library which might be "installed"/present at a different location. Often, Developers assume files are located at the same "place" on everyones machine....not always the case!
2) 您的“项目”引用了在指定位置不存在的文件(通常是头文件)。如果您从源代码控制系统中删除了一个文件,但忘记将其从项目中删除,或者因为您引用了可能“安装”/存在于不同位置的库的头文件,则可能会发生这种情况。通常,开发人员假设文件位于每个人的机器上的同一个“位置”......情况并非总是如此!
3) You have done some "refactoring" of your project, and moved files around to different subdirectories, or even renamed them - so the paths/names of the files recorded in the "tlog" do not match what exists on your disk i.e. stale.
3)您已经对您的项目进行了一些“重构”,并将文件移动到不同的子目录,甚至重命名它们 - 因此“tlog”中记录的文件的路径/名称与磁盘上存在的内容不匹配,即陈旧.
What is the way to fix it?
修复它的方法是什么?
Doing a "Clean+Build" or "Rebuild" does not always fix it...as those operations do not delete the "tlog" files. So:
执行“Clean+Build”或“Rebuild”并不总是能修复它……因为这些操作不会删除“tlog”文件。所以:
delete any "tlog" files that you can find in your solution/project directories and rebuild.
make sure your Project does not refer to non-existent files
删除您可以在解决方案/项目目录中找到的所有“tlog”文件并重建。
确保您的项目不引用不存在的文件
How do I work out which files are non-existent?
如何确定哪些文件不存在?
If you want to know/find out exactly which files Visual Studio is thinking are out of date, then you can turn on some diagnostic information in Visual Studio....and watch the messages in DebugView...showing the full path of the files it is probing.
如果您想确切地知道/找出 Visual Studio 认为哪些文件已过期,那么您可以在 Visual Studio 中打开一些诊断信息....并在 DebugView 中查看消息...显示完整路径它正在探测的文件。
In devenv.exe.config
you put:
在devenv.exe.config
你输入:
<system.diagnostics>
<switches>
<add name="CPS" value="4" />
</switches>
</system.diagnostics>
More Details
更多细节
Lets say you created a Solution and a set of Projects in a particular directory e.g. S:\MYPROJECTS, and you compile and run/debug it, etc.
假设您在特定目录(例如 S:\MYPROJECTS)中创建了一个解决方案和一组项目,然后编译并运行/调试它等。
You then decide to move that whole directory to somewhere else on your drive, or you re-factor your Projects e.g. change their directory names, etc.
然后您决定将整个目录移动到驱动器上的其他位置,或者重构您的项目,例如更改它们的目录名称等。
Now when you do a "Start Debugging/F5", Visual Studio does the depending checking, and thinks you have "out of date files".
现在,当您执行“开始调试/F5”时,Visual Studio 会进行相关检查,并认为您有“过时的文件”。
Even if you do a "Clean Solution", or a "Rebuild Solution"....you still get the "out of date files" message.
即使您执行“清洁解决方案”或“重建解决方案”....您仍然会收到“文件过期”消息。
See here:
看这里:
The problem is caused by the ".tlog" files which are being consulted during the dependency checks...when you moved the solutions/projects (along with a builds intermediate files) they cause confusion to the Visual Studio builder.
该问题是由在依赖项检查期间查阅的“.tlog”文件引起的......当您移动解决方案/项目(以及构建中间文件)时,它们会导致 Visual Studio 构建器的混淆。
The solution is to delete all the .tlog files.....they will then be re-generated the next time you do a build...and from that point on you won't get a bogus "out of date files" message....unless they truly are out of date.
解决方案是删除所有 .tlog 文件.....它们将在您下次构建时重新生成...从那时起您将不会得到虚假的“过时文件”消息......除非它们真的过时了。
回答by CrouZ
You should let Visual Studio tell you why it needs to rebuild. Visual Studio 2015has built in support for this:
您应该让 Visual Studio 告诉您为什么它需要重建。Visual Studio 2015内置了对此的支持:
- Tools (menu)
- Options
- Project and Solution
- Build and Run
- 工具(菜单)
- 选项
- 项目和解决方案
- 构建和运行
Change MSBuild project build output verbosity to Detailedor Diagnostics.
将 MSBuild 项目生成输出详细程度更改为详细或诊断。
In my case it printed a message like this:
在我的情况下,它打印了一条这样的消息:
1>------ Up-To-Date check: Project: xyz, Configuration: xyz ------
1>Project not up to date because build input 'C:\ws\Missing.h' is missing.
... and removing that header from the project fixed the problem.
...并从项目中删除该标题解决了问题。
To get this information in older Visual Studio versions, you need to use DebugView and modify devenv.exe.config
(see Colin Smith's answer: https://stackoverflow.com/a/21759835/1941779). Note that this solution does NOT work for Visual Studio 2015.
要在较旧的 Visual Studio 版本中获取此信息,您需要使用 DebugView 并进行修改devenv.exe.config
(请参阅 Colin Smith 的回答:https: //stackoverflow.com/a/21759835/1941779)。请注意,此解决方案不适用于 Visual Studio 2015。
回答by dankos
I too kept getting "The project out-of-date" error, even though there were no changes. I traced it to a header file listed in Solution Explorer that was no longer being used and had been deleted from the project's directory. Removing it from the SE list fixed the extraneous error message from popping up.
即使没有任何更改,我也不断收到“项目已过期”错误。我将其追踪到解决方案资源管理器中列出的头文件,该文件不再使用并已从项目目录中删除。从 SE 列表中删除它修复了弹出的无关错误消息。
回答by lucky zhao
I had this problem, too. In my case the reason was the references to files (usually header files), which do not exist at the location specified.
我也有这个问题。在我的情况下,原因是对文件(通常是头文件)的引用,这些文件在指定的位置不存在。
回答by Stephen Edmonds
I ran into this problem and, using the diagnostics trick that colinsmith posted about, was able to trace the problem back to the fact that my .vcxproj was referencing a file that didn't actually exist anywhere (It had been deleted a long time ago, but never removed from the project file).
我遇到了这个问题,并且使用 colinsmith 发布的诊断技巧,能够将问题追溯到我的 .vcxproj 引用的文件实际上在任何地方都不存在的事实(它很久以前就被删除了) ,但从未从项目文件中删除)。
回答by yano
Just for posterity, I was getting this problem, and then realized my computer clock had somehow jumped approximately 48 hours into the past. After I set it back to current time, the warning went away.
只是为了后代,我遇到了这个问题,然后意识到我的电脑时钟不知何故跳到了过去大约 48 小时。在我将其设置回当前时间后,警告消失了。