1

我在我的 xamarin android 项目中添加了一个组件。现在,当我的项目在 appveyor 中运行时,它在这一点上失败了:

$zipPath = "$($env:APPVEYOR_BUILD_FOLDER)\xpkg.zip"
(New-Object Net.WebClient).DownloadFile('https://components.xamarin.com/submit/xpkg', $zipPath)
7z x $zipPath | Out-Null
Command exited with code 2

它在我的环境中构建并运行良好。可能是什么问题呢?

4

1 回答 1

2

退出代码 2:

Unrecognized command.

它没有7z为您的解压缩/提取步骤找到命令。

get-7zip.ps1如果您还没有,请尝试:


Write-Host "Installing 7-Zip ..."
$instPath = "$env:ProgramFiles\7-Zip\7z.exe"
if (!(Test-Path $instPath))
{
    Write-Host "Determining download URL ..."
    $web = New-Object System.Net.WebClient
    $page = $web.DownloadString("http://www.7-zip.org/download.html")

    $64bit = ''

    if ($env:PROCESSOR_ARCHITECTURE -match '64')
    {
        $64bit = 'x64'
    }

    $pattern = "(http://.*?${64bit}\.msi)"
    $url = $page | Select-String -Pattern $pattern | Select-Object -ExpandProperty Matches -First 1 | foreach { $_.Value }

    $file = "$env:TEMP\7z.msi"
    if (Test-Path $file)
    {    
        rm $file | Out-Null
    }

    Write-Host "Downloading $url -> $file"

    $web.DownloadFile($url, $file)

    Write-Host "Installing..."
    Write-Host "(Note: please approve the User Account Control (UAC) popup if necessary...)"

    $cmd = "$file /passive"

    Invoke-Expression $cmd | Out-Null

    while (!(Test-Path $instPath))
    {
        Start-Sleep -Seconds 10
    }

    Write-Host "Done!"
}
else
{
    Write-Host "7-Zip already installed."
}

https://raw.githubusercontent.com/dougthor42/wafer_map/478faec644c06887d2cf6823457ac8e63a47ce77/appveyor/get-7zip.ps1

于 2016-04-21T08:24:44.543 回答