I have a Powershell script that needs to set a custom build variable, such that it can be used in a later task. I have successfully added a variable, and verified it can be accessed and set from Powershell, but, for whatever reason, the change does not persist when referencing the variable in a later build step.
Write-Host $env:VERSIONNUMBER #prints the variable value set in TFS Build
$env:VERSIONNUMBER = 'This doesn't stick'
Write-Host $env:VERSIONNUMBER #prints 'This doesn't stick', but not available after this task