TFS Build vNext: How to write to a custom build variable from Powershell

点点圈 提交于 2019-12-11 09:11:14

问题


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

回答1:


Try the following in your PowerShell script

Write-Host “##vso[task.setvariable variable=myvariable]newValue”

this worked for me in Release Management vNext, but I would assume it also works in the build system as well.



来源:https://stackoverflow.com/questions/33358708/tfs-build-vnext-how-to-write-to-a-custom-build-variable-from-powershell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!