如何将 TFS 变量传递给项目的 MSBuild 任务

发布于 2024-12-29 12:54:45 字数 384 浏览 4 评论 0原文

我有一个基于 TFS 服务器构建的解决方案。该解决方案包括多个具有自定义 MSBuild 任务的项目。这些任务实际上创建了一些 zip 存档。

我需要以某种方式从 TFS 构建中提取 $(Rev) 宏并将其传递给任务。我尝试在构建定义的进程选项卡中使用 MSBuildArguments,当我设置一个简单的字符串值(例如

/p:Version="5")

时它可以工作,但它不适用于宏:

/p:Version="$ (Rev:r)"

在此处输入图像描述

您有什么想法吗?

编辑:我实际上需要 BuildDetail.BuildNumber。

I have a solution which is built on TFS server. This solution includes several projects which have custom MSBuild tasks. Theses tasks actually create some zip archives.

I need to extract somehow the $(Rev) macros from the TFS build and pass it to the tasks. I tried to use MSBuildArguments in the process tab of the build definition and it works when I set a simple string value like:

/p:Version="5"

but it doesn't work with the macros:

/p:Version="$(Rev:r)"

enter image description here

do you have any ideas?

Edit: I actually needed BuildDetail.BuildNumber.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

此刻的回忆 2025-01-05 12:54:45

您可以稍微更改构建过程模板来实现这一点。
默认情况下,与 MSBuild 相关的部分如下所示:
在此处输入图像描述
这可以扩展为如下所示:
在此处输入图像描述

如果你现在在构建定义的“MSBuild Arguments”中输入类似 /p:Version=RePlAcE 的内容(类似于您的图片),您应该会得到您需要的内容。

在另一个构建定义中如果不需要,只需将条目留空即可。此方法是此处,如果所有使用它的构建定义都没有明确需要此版本插入,则应选择该版本。

You can slightly change your build process template to achieve that.
By default the section that relates to MSBuild looks like this:
enter image description here
This could be expanded into something like this:
enter image description here

If you now enter in "MSBuild Arguments" of your build definition (similar to your picture) something like /p:Version=RePlAcE, you should get what you need.

In another build definition where you don't need this, simply leave the entry empty. This approach is an alternative to the one found here, and should be chosen if this version-insertion is not explicitly desired for all build definitions consuming it.

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