Skip to content

Commit

Permalink
[fetchDependency] Call Start-BitsTransfer if available, otherwise fal…
Browse files Browse the repository at this point in the history
…lback
  • Loading branch information
alexkaratarakis committed Oct 17, 2017
1 parent 451c1c9 commit d6d5540
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions scripts/fetchDependency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,26 @@ 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)
{
Remove-Item $downloadPath
}
}
}
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+.
Expand Down

0 comments on commit d6d5540

Please sign in to comment.