Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions provisioning/windows-provision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -342,27 +342,40 @@ if("2019" -eq $env:AGENT_OS_VERSION) {
AddToPathEnv $baseDir

## Proceed to install tools
# TODO: foreach in parallel for downloads
$jobs = @()

Write-Host "Downloading all tools..."
foreach($k in $downloads.Keys) {
Write-Host "---"
$download = $downloads[$k]
if($download.ContainsKey('check')) {
$res = Invoke-Command $download['check']
if(!$res) {
Write-Host "Check did not pass, not setting up $k"
continue;
}
if(-Not ($download.ContainsKey('preExpand')) -and ($download.ContainsKey('expandTo'))) {
$expendTo = $download['expandTo']
} else {
$expendTo = $false
}
Write-Host "Downloading and setting up $k"

DownloadFile $download['url'] $download['local']
$jobs += Start-Job -ScriptBlock {
param($url, $local, $expendTo)
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $url -OutFile $local
if ($expendTo) {
Expand-Archive -Path $local -DestinationPath $expendTo
}
} -ArgumentList $download.url, $download.local, $expendTo
}

Wait-Job $jobs
Receive-Job $jobs

foreach($k in $downloads.Keys) {
Write-Host "---"
$download = $downloads[$k]
Write-Host "Setting up $k"

if($download.ContainsKey('preExpand')) {
Invoke-Command -ScriptBlock $download['preExpand']
}

if($download.ContainsKey('expandTo')) {
Expand-Archive -Path $download['local'] -DestinationPath $download['expandTo']
if($download.ContainsKey('expandTo')) {
Expand-Archive -Path $download['local'] -DestinationPath $download['expandTo']
}
}

if($download.ContainsKey('postExpand')) {
Expand Down