diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-10-17 13:45:41 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-10-17 13:54:41 -0700 |
| commit | d6d5540cc54c5d3dcbb43bdc6d0fd5b2d6271d21 (patch) | |
| tree | c61baa7ed11f619b53ec1eb45aaf6a334bc2c9d3 /scripts | |
| parent | 451c1c96be2407da0e590344c655a8df838d3f99 (diff) | |
| download | vcpkg-d6d5540cc54c5d3dcbb43bdc6d0fd5b2d6271d21.tar.gz vcpkg-d6d5540cc54c5d3dcbb43bdc6d0fd5b2d6271d21.zip | |
[fetchDependency] Call Start-BitsTransfer if available, otherwise fallback
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/fetchDependency.ps1 | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 58f64b626..d2e2b89fd 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -57,12 +57,16 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $WC.Proxy.Credentials=$ProxyCred } - if (($PSVersionTable.PSEdition -ne "Core") -and ($Dependency -ne "git")) # git fails with BITS + # git and installerbase fail with Start-BitsTransfer + if ((Test-Command -commandName 'Start-BitsTransfer') -and ($Dependency -ne "git")-and ($Dependency -ne "installerbase")) { - try { + try + { Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop + return } - catch [System.Exception] { + catch [System.Exception] + { # If BITS fails for any reason, delete any potentially partially downloaded files and continue if (Test-Path $downloadPath) { @@ -70,11 +74,9 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) } } } - if (!(Test-Path $downloadPath)) - { - Write-Verbose("Downloading $Dependency...") - $WC.DownloadFile($url, $downloadPath) - } + + Write-Verbose("Downloading $Dependency...") + $WC.DownloadFile($url, $downloadPath) } # Enums (without resorting to C#) are only available on powershell 5+. |
