Visual Studio:运行 C++项目构建后事件,即使项目是最新的
在 Visual Studio (2008) 中,即使项目是最新的,是否也可以强制 C++ 项目的构建后事件运行?
具体来说,我有一个构建 COM 进程内服务器 DLL 的项目。该项目有一个运行“regsvr32.exe $(TargetPath)”的构建后步骤。这在“重建”上运行良好,但仅当对项目源进行更改时才在“构建”上运行。
如果我执行“构建”而不进行任何更改,Visual Studio 只会报告该项目是最新的并且不执行任何操作 - 构建后事件不会运行。在这种情况下有什么方法可以强制事件运行吗?这是必要的,因为虽然 DLL 本身是最新的,但注册信息可能不是。
In Visual Studio (2008) is it possible to force the Post-Build Event for a C++ project to run even if the project is up-to-date?
Specifically, I have a project which builds a COM in-process server DLL. The project has a post-build step which runs "regsvr32.exe $(TargetPath)". This runs fine on a "Rebuild", but runs on a "Build" only if changes have been made to the project's source.
If I do a "Build" without making any changes, Visual Studio simply reports that the project is up-to-date and does nothing - the Post-Build Event is not run. Is there any way that I can force the Event to run in this situation? This is necessary since although the DLL itself is up-to-date, the registration information may not be.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用自定义构建步骤属性页来设置要运行的批处理文件。如果在输出设置中指定的文件未找到或已过期,则会运行此命令。只需在那里指定一些不存在的文件,自定义构建步骤将始终运行。即使您的项目是最新的,它也会运行,因为永远找不到输出文件。
You can use the Custom Build Step property page to set up a batch file to run. This runs if the File specified in the Outputs setting is not found, or is out-of-date. Simply specify some non-existent file there, and the custom build step will always run. It will run even if your project is up-to-date, since the Output file is never found.
使用此DisableFastUpToDateCheck
查看示例:
Use this DisableFastUpToDateCheck
See an example:
在 Visual Studio 2017(也许还有其他版本)中,对于 C# 项目(尚未根据 OP 的实际问题检查 C++ 项目),有一个选项“运行构建后事件:”,一个选项是“始终” ,即使没有任何更改,它也会运行构建后,而不是简单地报告项目是最新的:
In Visual Studio 2017 (perhaps other versions as well), for C# projects (haven't checked for C++ projects per OP's actual question) there is an option for "Run the post-build event:", and one option is "Always", which will run the Post-Build even if nothing has changed, rather than simply reporting that the project is up to date:
注册信息很大程度上取决于
.rgs
文件中的内容。如果该文件发生更改,项目将被构建。我不确定如何在不弄脏项目的情况下更改 COM 注册。您介意提供有关您的具体情况的更多详细信息吗?The registration information is determined largely by what's in the
.rgs
file. If that file changes the project will get built. I am not sure how else COM registration can change without making the project dirty. Do you mind providing more details about your particular situation?