libuv-build/build.ps1

68 строки
1.7 KiB
PowerShell
Исходник Постоянная ссылка Обычный вид История

$ErrorActionPreference = "Stop"
2017-03-02 01:46:20 +03:00
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
{
while($true)
{
try
{
Invoke-WebRequest $url -OutFile $downloadLocation
break
}
catch
{
$exceptionMessage = $_.Exception.Message
Write-Host "Failed to download '$url': $exceptionMessage"
if ($retries -gt 0) {
$retries--
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
Start-Sleep -Seconds 10
}
2017-03-02 01:46:20 +03:00
else
{
$exception = $_.Exception
throw $exception
}
}
}
}
2016-02-27 23:51:11 +03:00
cd $PSScriptRoot
$repoFolder = $PSScriptRoot
$env:REPO_FOLDER = $repoFolder
2017-03-02 01:46:20 +03:00
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/legacy-build.zip"
2016-02-27 23:51:11 +03:00
if ($env:KOREBUILD_ZIP)
{
$koreBuildZip=$env:KOREBUILD_ZIP
}
$buildFolder = ".build"
$buildFile="$buildFolder\KoreBuild.ps1"
if (!(Test-Path $buildFolder)) {
2017-03-02 01:46:20 +03:00
Write-Host "Downloading KoreBuild from $koreBuildZip"
2016-02-27 23:51:11 +03:00
$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
New-Item -Path "$tempFolder" -Type directory | Out-Null
$localZipFile="$tempFolder\korebuild.zip"
2017-03-02 01:46:20 +03:00
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6
2016-02-27 23:51:11 +03:00
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)
2017-03-02 01:46:20 +03:00
2016-02-27 23:51:11 +03:00
New-Item -Path "$buildFolder" -Type directory | Out-Null
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse
# Cleanup
if (Test-Path $tempFolder) {
Remove-Item -Recurse -Force $tempFolder
}
}
2017-03-02 01:46:20 +03:00
&"$buildFile" $args