设置“路径"vsts 构建期间的环境变量,因此它会在构建任务中持续存在,特别是 vsTest 任务 [英] Set "Path" environment variable during vsts build so it would persist across build tasks specifically vsTest task
本文介绍了设置“路径"vsts 构建期间的环境变量,因此它会在构建任务中持续存在,特别是 vsTest 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 vsts 构建定义,其中我尝试使用 PowerShell(以及在我尝试 cmd 之前)任务设置 PATH 环境变量,以便在稍后的 vsTest 任务中,测试可以从该路径运行 exe,但是设置使用 pscmd 任务的 PATH 似乎不起作用,我尝试了几个选项,例如:
I have a vsts build definition in which I try to set the PATH environment variable using PowerShell (and before I tried cmd) task, so that in a later vsTest task, the tests could run an exe from that path, however setting the PATH using the pscmd tasks doesn’t seem to work, I tried a few options such as:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + $newPath, [EnvironmentVariableTarget]::User)
setx path " %newPath;%PATH%"
有什么建议吗?
推荐答案
通过调用通过 PowerShell 任务记录命令:
例如:
Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};$newPath";
这篇关于设置“路径"vsts 构建期间的环境变量,因此它会在构建任务中持续存在,特别是 vsTest 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文