如何将 TFS 变量传递给项目的 MSBuild 任务
我有一个基于 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)"
do you have any ideas?
Edit: I actually needed BuildDetail.BuildNumber.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以稍微更改构建过程模板来实现这一点。


默认情况下,与 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:
This could be expanded into something like this:
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.