无法将 zip 解压缩到默认使用 Extract Task 的目标它失败并出现错误:
##[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 设置,但也失败并出现相同的错误。
更新
问题似乎是由代理权限引起的。仍然无法在服务模式下以管理员权限执行Release。当以管理员身份在交互模式下运行时,发布成功执行。
只要需要管理员权限,任务就会失败。
最佳答案
从错误消息来看,您的自托管代理上似乎未安装 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
关于Azure 管道提取任务 7zip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72548321/