13
votes

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.

1
May I ask what makes you think those are macros?John Saunders
Hm, I just thought it is called macros. Check the build number format - it is built with these macros. Am I wrong? I'm a newbie in TFS.Andrey Selitsky
Yes, they're not general. The build number format thing is specific to the build number.John Saunders
Actually I need just to add some unique number of a current build to the archive names. Could you suggest anything?Andrey Selitsky

1 Answers

14
votes

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.