From 504545d2c864623ebddf169b1e402326bfe136f4 Mon Sep 17 00:00:00 2001 From: Ben Harper Date: Mon, 6 Feb 2017 14:44:59 +0200 Subject: [PATCH] Add a workaround for another BITS code path The fix from last week (ce9927f7327bc71ade246108a7d984deda6293fd) worked for downloading most dependencies, but there is still one BITS transfer code path, which this fix addresses. --- .../findVisualStudioInstallationInstances.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1 index a2ce66522..9d54990a2 100644 --- a/scripts/findVisualStudioInstallationInstances.ps1 +++ b/scripts/findVisualStudioInstallationInstances.ps1 @@ -20,7 +20,21 @@ $downloadPath = "$downloadsDir\$downloadName" if (!(Test-Path $downloadPath)) { - Start-BitsTransfer -Source $url -Destination $downloadPath #-ErrorAction SilentlyContinue + try { + Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop + } + catch [System.Exception] { + # If BITS fails for any reason, delete any potentially partially downloaded files and continue + if (Test-Path $downloadPath) + { + Remove-Item $downloadPath + } + } +} +if (!(Test-Path $downloadPath)) +{ + Write-Host("Downloading $downloadName...") + (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath) } $nugetOutput = & $nugetexe install Microsoft.VisualStudio.Setup.Configuration.Native -Pre -Source $downloadsDir -OutputDirectory $nugetPackageDir 2>&1