简体   繁体   中英

Using Variables in a TFS Build Template

We created a build template that accepts the path of a powerscript filename as an argument. Right now it works if I type in the actual path of the script. I would like to pass $(SourceDir) as part of the path, and then replace it with the actual value during the build.

For example: $(SourceDir) \\myapp\\scripts\\scripttorun.ps

Here are the steps that I have done:

  • In the template I have created a variable named DeploymentScript
  • Then ConvertWorkspaceItem DeploymentScript -> DeploymentScriptFilename
  • Then pass DeploymentScriptFilename as an argument to PowerShell

Possibly duplicate with this case TFS How to GetEnvironmentVariable value . You can't use $TF_BUILD_BUILDDIRECTORY in a custom build process.

Refer to the last paragraph in this MSDN document :

Use environment data from a custom build process

If you need to use an environment variable in your custom build process template , you can use the GetEnvironmentVariable activity to get the data. You can get data from any of the WellKnownEnvironmentVariables .

For example, to get the path to the binaries directory, set the Name property of the GetEnvironmentVariable activity to Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.BinariesDirectory

Please refer more detailed info about how to use it from this blog Using Environment Variables in Visual Studio 2013 and TFS 2013

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM