|
|
|
@ -193,38 +193,42 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) { |
|
|
|
return $global:_DotNetInstallDir = $dotnetRoot |
|
|
|
} |
|
|
|
|
|
|
|
function Retry($downloadBlock, $maxRetries = 5) { |
|
|
|
$retries = 1 |
|
|
|
|
|
|
|
while($true) { |
|
|
|
try { |
|
|
|
& $downloadBlock |
|
|
|
break |
|
|
|
} |
|
|
|
catch { |
|
|
|
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ |
|
|
|
} |
|
|
|
|
|
|
|
if (++$retries -le $maxRetries) { |
|
|
|
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff |
|
|
|
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)." |
|
|
|
Start-Sleep -Seconds $delayInSeconds |
|
|
|
} |
|
|
|
else { |
|
|
|
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unable to download file in $maxRetries attempts." |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function GetDotNetInstallScript([string] $dotnetRoot) { |
|
|
|
$installScript = Join-Path $dotnetRoot 'dotnet-install.ps1' |
|
|
|
if (!(Test-Path $installScript)) { |
|
|
|
Create-Directory $dotnetRoot |
|
|
|
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit |
|
|
|
|
|
|
|
$maxRetries = 5 |
|
|
|
$retries = 1 |
|
|
|
|
|
|
|
$uri = "https://dot.net/$dotnetInstallScriptVersion/dotnet-install.ps1" |
|
|
|
|
|
|
|
while($true) { |
|
|
|
try { |
|
|
|
Write-Host "GET $uri" |
|
|
|
Invoke-WebRequest $uri -OutFile $installScript |
|
|
|
break |
|
|
|
} |
|
|
|
catch { |
|
|
|
Write-Host "Failed to download '$uri'" |
|
|
|
Write-Error $_.Exception.Message -ErrorAction Continue |
|
|
|
} |
|
|
|
|
|
|
|
if (++$retries -le $maxRetries) { |
|
|
|
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff |
|
|
|
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)." |
|
|
|
Start-Sleep -Seconds $delayInSeconds |
|
|
|
} |
|
|
|
else { |
|
|
|
throw "Unable to download file in $maxRetries attempts." |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
Retry({ |
|
|
|
Write-Host "GET $uri" |
|
|
|
Invoke-WebRequest $uri -OutFile $installScript |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
return $installScript |
|
|
|
@ -308,8 +312,8 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = |
|
|
|
|
|
|
|
# If the version of msbuild is going to be xcopied, |
|
|
|
# use this version. Version matches a package here: |
|
|
|
# https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet-eng&package=RoslynTools.MSBuild&protocolType=NuGet&version=16.8.0-preview3&view=overview |
|
|
|
$defaultXCopyMSBuildVersion = '16.8.0-preview3' |
|
|
|
# https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet-eng&package=RoslynTools.MSBuild&protocolType=NuGet&version=16.10.0-preview2&view=overview |
|
|
|
$defaultXCopyMSBuildVersion = '16.10.0-preview2' |
|
|
|
|
|
|
|
if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } |
|
|
|
$vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { $vsMinVersionReqdStr } |
|
|
|
@ -403,9 +407,13 @@ function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) { |
|
|
|
} |
|
|
|
|
|
|
|
Create-Directory $packageDir |
|
|
|
|
|
|
|
Write-Host "Downloading $packageName $packageVersion" |
|
|
|
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit |
|
|
|
Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -OutFile $packagePath |
|
|
|
Retry({ |
|
|
|
Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -OutFile $packagePath |
|
|
|
}) |
|
|
|
|
|
|
|
Unzip $packagePath $packageDir |
|
|
|
} |
|
|
|
|
|
|
|
@ -442,27 +450,9 @@ function LocateVisualStudio([object]$vsRequirements = $null){ |
|
|
|
if (!(Test-Path $vsWhereExe)) { |
|
|
|
Create-Directory $vsWhereDir |
|
|
|
Write-Host 'Downloading vswhere' |
|
|
|
$maxRetries = 5 |
|
|
|
$retries = 1 |
|
|
|
|
|
|
|
while($true) { |
|
|
|
try { |
|
|
|
Invoke-WebRequest "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/vswhere/$vswhereVersion/vswhere.exe" -OutFile $vswhereExe |
|
|
|
break |
|
|
|
} |
|
|
|
catch{ |
|
|
|
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ |
|
|
|
} |
|
|
|
|
|
|
|
if (++$retries -le $maxRetries) { |
|
|
|
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff |
|
|
|
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)." |
|
|
|
Start-Sleep -Seconds $delayInSeconds |
|
|
|
} |
|
|
|
else { |
|
|
|
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unable to download file in $maxRetries attempts." |
|
|
|
} |
|
|
|
} |
|
|
|
Retry({ |
|
|
|
Invoke-WebRequest "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/vswhere/$vswhereVersion/vswhere.exe" -OutFile $vswhereExe |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } |
|
|
|
@ -498,7 +488,7 @@ function InitializeBuildTool() { |
|
|
|
if (Test-Path variable:global:_BuildTool) { |
|
|
|
# If the requested msbuild parameters do not match, clear the cached variables. |
|
|
|
if($global:_BuildTool.Contains('ExcludePrereleaseVS') -and $global:_BuildTool.ExcludePrereleaseVS -ne $excludePrereleaseVS) { |
|
|
|
Remove-Item variable:global:_BuildTool |
|
|
|
Remove-Item variable:global:_BuildTool |
|
|
|
Remove-Item variable:global:_MSBuildExe |
|
|
|
} else { |
|
|
|
return $global:_BuildTool |
|
|
|
@ -555,7 +545,7 @@ function GetDefaultMSBuildEngine() { |
|
|
|
|
|
|
|
function GetNuGetPackageCachePath() { |
|
|
|
if ($env:NUGET_PACKAGES -eq $null) { |
|
|
|
# Use local cache on CI to ensure deterministic build. |
|
|
|
# Use local cache on CI to ensure deterministic build. |
|
|
|
# Avoid using the http cache as workaround for https://github.com/NuGet/Home/issues/3116 |
|
|
|
# use global cache in dev builds to avoid cost of downloading packages. |
|
|
|
# For directory normalization, see also: https://github.com/NuGet/Home/issues/7968 |
|
|
|
@ -712,7 +702,10 @@ function MSBuild-Core() { |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($arg in $args) { |
|
|
|
if ($arg -ne $null -and $arg.Trim() -ne "") { |
|
|
|
if ($null -ne $arg -and $arg.Trim() -ne "") { |
|
|
|
if ($arg.EndsWith('\')) { |
|
|
|
$arg = $arg + "\" |
|
|
|
} |
|
|
|
$cmdArgs += " `"$arg`"" |
|
|
|
} |
|
|
|
} |
|
|
|
@ -784,7 +777,7 @@ function Get-Darc($version) { |
|
|
|
|
|
|
|
. $PSScriptRoot\pipeline-logging-functions.ps1 |
|
|
|
|
|
|
|
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..') |
|
|
|
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\') |
|
|
|
$EngRoot = Resolve-Path (Join-Path $PSScriptRoot '..') |
|
|
|
$ArtifactsDir = Join-Path $RepoRoot 'artifacts' |
|
|
|
$ToolsetDir = Join-Path $ArtifactsDir 'toolset' |
|
|
|
|