【问题标题】:Azure Pipeline Extract Task 7zipAzure 管道提取任务 7zip
【发布时间】:2022-06-10 17:33:58
【问题描述】:
默认使用 Extract Task 时无法将 zip 解压缩到目标位置,但失败并出现错误:
##[error]Unable to locate executable file: 'C:\azagent\A5\_work\_tasks\ExtractFiles_5e1e3830-fbfb-11e5-aab1-090c92bc4988\1.200.0\7zip\7z.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
说明它无法找到默认的 7zip 路径。尝试使用自定义 PATH 设置,但同样失败。
【问题讨论】:
标签:
azure
azure-devops
azure-pipelines
task
【解决方案1】:
从错误消息来看,7zip 似乎没有安装在您的自托管代理上。在使用提取任务之前尝试安装 7zip。
以 Bash Task 为例:
brew install p7zip
对于 Windows,请使用以下 PowerShell 脚本进行安装:
$dlurl = 'https://7-zip.org/' + (Invoke-WebRequest -UseBasicParsing -Uri 'https://7-zip.org/' | Select-Object -ExpandProperty Links | Where-Object {($_.outerHTML -match 'Download')-and ($_.href -like "a/*") -and ($_.href -like "*-x64.exe")} | Select-Object -First 1 | Select-Object -ExpandProperty href)
# modified to work without IE
# above code from: https://perplexity.nl/windows-powershell/installing-or-updating-7-zip-using-powershell/
$installerPath = Join-Path $env:TEMP (Split-Path $dlurl -Leaf)
Invoke-WebRequest $dlurl -OutFile $installerPath
Start-Process -FilePath $installerPath -Args "/S" -Verb RunAs -Wait
Remove-Item $installerPath