How to pass TFS variable to a MSBuild task of the project [duplicate]

狂风中的少年 提交于 2019-12-17 19:48:50

问题


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.


回答1:


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.

来源:https://stackoverflow.com/questions/9030328/how-to-pass-tfs-variable-to-a-msbuild-task-of-the-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!