gpt4 book ai didi

powershell - 在 Yaml 管道中修复 PowerShell

转载 作者:行者123 更新时间:2023-12-04 03:31:45 30 4
gpt4 key购买 nike

我有一个现有的 Yaml 管道,我正在尝试理解和修复某些问题。因为我是新手,所以在这个现有的管道中我无法理解的东西很少。我想知道下面的任务在做什么。我在这里没有看到任何内联 PowerShell 脚本,这就是为什么将其创建为 PowerShell 的原因。任务是在 ABC_x64-$(osSuffix)\bin 文件夹中添加 POMLXX dll,但下面的脚本是如何做到的

- powershell: |
Set-Variable -Name PATH -Value "$env:PATH;$(IppRoot)\redist\intel64_win\ipp;$(Build.SourcesDirectory)\ABC_x64-$(osSuffix)\bin;$(Build.BinariesDirectory);$(PuLib)/imports/Pulib67/dll/amd64;$(POMLXX)/runtimes/win-x64/native"
Write-Host "##vso[task.setvariable variable=PATH]$PATH"
displayName: 'Add AbcRoot, IPP binaries, Pulib67 and POMLXX to PATH on Win'
condition: eq(variables['Agent.OS'], 'Windows_NT')

- bash: |
export LD_LIBRARY_PATH="$(IppRoot)/redist/intel64_win/ipp:$(Build.SourcesDirectory)/MyProject_x64-$(osSuffix)/lib"
echo "##vso[task.setvariable variable=LD_LIBRARY_PATH]$LD_LIBRARY_PATH"
echo "##vso[task.setvariable variable=DYLD_LIBRARY_PATH]$LD_LIBRARY_PATH"
displayName: 'Add OrzRoot, IPP binaries and LibFT4222 to (DY)LD_LIBRARY_PATH on Linux and Mac'
condition: in(variables['Agent.OS'], 'Darwin', 'Linux')

最佳答案

这 block 是powershell:

Set-Variable -Name PATH -Value "$env:PATH;$(IppRoot)\redist\intel64_win\ipp;$(Build.SourcesDirectory)\ABC_x64-$(osSuffix)\bin;$(Build.BinariesDirectory);$(PuLib)/imports/Pulib67/dll/amd64;$(POMLXX)/runtimes/win-x64/native"
Write-Host "##vso[task.setvariable variable=PATH]$PATH"

它将一堆路径添加到 PATH powershell 变量 (set-variable -Name PATH),包括从代理下来的路径环境变量,然后将其导出回代理 ( Write-Host 使用特殊的命令字符串)通过重新设置 Azure Pipelines PATH 变量。该变量将在后续任务的上下文中设置,以便他们可以找到工具。

将对环境的更改保留到同一作业上下文中的新任务有点困难。

另见:

powershell: 之后的 | 指示 YAML 解析器将下一个缩进 block 解释为多行字符串。

另见:

更好的解决方案

有一个更好的解决方案,看起来很相似:

powershell: |
write-host "##vso[task.prependpath]$(IppRoot)\redist\intel64_win\ipp"
write-host "##vso[task.prependpath]$(Build.SourcesDirectory)\ABC_x64-$(osSuffix)\bin"
... etc

此命令是专门为将路径添加到 PATH 环境而创建的,即使其他工具安装程序任务在您的脚本部分之后运行,它也能正常工作。

另见:

关于powershell - 在 Yaml 管道中修复 PowerShell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66655609/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com