问题描述
我有一个建立在 TFS 服务器上的解决方案.此解决方案包括多个具有自定义 MSBuild 任务的项目.这些任务实际上创建了一些 zip 档案.
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.
我需要以某种方式从 TFS 构建中提取 $(Rev) 宏并将其传递给任务.我尝试在构建定义的进程选项卡中使用 MSBuildArguments,当我设置一个简单的字符串值时它可以工作,例如:
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"
/p:Version="5"
但它不适用于宏:
/p:Version="$(Rev:r)"
/p:Version="$(Rev:r)"
你有什么想法吗?
我实际上需要 BuildDetail.BuildNumber.
I actually needed BuildDetail.BuildNumber.
推荐答案
您可以稍微更改构建过程模板来实现这一点.
默认情况下,与 MSBuild 相关的部分如下所示:
这可以扩展成这样:
如果您现在输入构建定义的MSBuild 参数"(类似于您的图片),则类似于 /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.
这篇关于如何将 TFS 变量传递给项目的 MSBuild 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!