Steve L.
Steve L.

Reputation: 1138

Assign Global Variable/Argument for Any Build to Use

I have several (15 or so) builds which all reference the same string of text in their respective build process templates. Every 90 days that text expires and needs to be updated in each of the templates. Is there a way to create a central variable or argument

Upvotes: 6

Views: 4563

Answers (2)

SoftwareCarpenter
SoftwareCarpenter

Reputation: 3923

One solution would be to create an environment variable on your build machine. Then reference the variable in all of your builds. When you needed to update the value you would only have to set it in one place.

How to: Use Environment Variables in a Build

If you have more than one build machine then it could become too much of a maintenance issue.

Another solution would involve using MSBuild response files. You create an .rsp file that holds the property value and the value would be picked up and set from MSBuild via the command line.

Upvotes: 2

Dylan Smith
Dylan Smith

Reputation: 22255

You need to place it into somewhere where all your builds can access it, then customize your build process template to read from there (build definitions - as you know - do not have a mechanism to share data between defs).

Some examples would be a file checked into TFS, a file in a known location (file share), web page, web service, etc.

You could even make a custom activity that knew how to read it and output the result as an OutArgument (e.g. Custom activity that read the string from a hardcoded URL).

Upvotes: 1

Related Questions