5
votes

We have a VNext build definition, on the Variables tab we have added a few custom variables. In one of the variable values we refer to another variable, i.e.

FileDescription = $(Build.DefinitionName)

However it appears that when we reference it in a PowerShell script the FILEDESCRIPTION environment variable exists but the value is not expanded(it contains "$(Build.DefinitionName)" ) and is treated as a string literal.

The documentation appears to suggest that we should be able to refer to it and it will be subsituted at run-time - https://msdn.microsoft.com/en-us/library/vs/alm/build/scripts/variables

Is there a way to get TFS to automatically expand the variable at runtime?

1

1 Answers

0
votes

In vNext build, it seems not expanded the variable everywhere.

For example, in MSBuild-Arguments, /p:OUTPUT="$(FileDescription)" is expanded to /p:OUTPUT="(the name of build definition)" , but in powershell it will only prints "$(Build.DefinitionName)" directly.

Try to use below Workaround: Try to use the corresponding generated environment variables (for example $env:Build.DefinitionName).

$FileDescription = $env:Build.DefinitionName 

Note: If you need to change the path, you have to change the PS script instead of a build variable.