Visual Studio:运行 C++项目构建后事件,即使项目是最新的

发布于 2024-08-15 11:55:28 字数 308 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

行至春深 2024-08-22 11:55:28

您可以使用自定义构建步骤属性页来设置要运行的批处理文件。如果在输出设置中指定的文件未找到或已过期,则会运行此命令。只需在那里指定一些不存在的文件,自定义构建步骤将始终运行。即使您的项目是最新的,它也会运行,因为永远找不到输出文件。

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.

狼性发作 2024-08-22 11:55:28

使用此DisableFastUpToDateCheck

查看示例:

<PropertyGroup>
    <PostBuildEvent>IF  EXIST C:\Projects\Copy_Files_To_Instance.ps1 ( powershell -file C:\Projects\Copy_Files_To_Instance.ps1)</PostBuildEvent>
    <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

Use this DisableFastUpToDateCheck

See an example:

<PropertyGroup>
    <PostBuildEvent>IF  EXIST C:\Projects\Copy_Files_To_Instance.ps1 ( powershell -file C:\Projects\Copy_Files_To_Instance.ps1)</PostBuildEvent>
    <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

意中人 2024-08-22 11:55:28

在 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:

enter image description here

暗恋未遂 2024-08-22 11:55:28

注册信息很大程度上取决于 .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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文