TFS 2015 Build Variable Extension

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

FileDescription = $(Build.DefinitionName) 

However, it turns out that when we refer to it in a PowerShell script, the FILEDESCRIPTION environment FILEDESCRIPTION exists, but the value is not expanded (it contains " $(Build.DefinitionName) ") and is treated as a string literal.

The documentation seems to suggest that we should be able to access it and it will be replaced 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 a variable at runtime?

+5
source share
1 answer

The vNext build does not seem to have expanded the variable worldwide.

For example, in MSBuild Arguments, /p:OUTPUT="$(FileDescription)" expands to / p: OUTPUT = "(assembly definition name)", but in powershell it will only print "$(Build.DefinitionName)" directly.

Try using the Workaround below: Try using the appropriate generated environment variables (e.g. $ env: Build.DefinitionName ).

 $FileDescription = $env:Build.DefinitionName 

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

0
source

Source: https://habr.com/ru/post/1245097/


All Articles