diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-10-12 10:52:00 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-10-12 10:52:00 -0700 |
| commit | 9ddc98988fb8d7c886963fa7568395ecd5785eaa (patch) | |
| tree | 9d9b6c81466e2a7e90e0aa08006f1064246656ea /scripts | |
| parent | 0ba3c166d76a4484fd4d378dc7367f2794577a20 (diff) | |
| download | vcpkg-9ddc98988fb8d7c886963fa7568395ecd5785eaa.tar.gz vcpkg-9ddc98988fb8d7c886963fa7568395ecd5785eaa.zip | |
[vcpkg-scripts] Detect and prompt for proxy in more cases
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/bootstrap.ps1 | 4 | ||||
| -rw-r--r-- | scripts/fetchDependency.ps1 | 20 |
2 files changed, 11 insertions, 13 deletions
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index fa51de404..b7bc5afab 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -4,10 +4,6 @@ param( [string]$disableMetrics = "0" ) -$webclient=New-Object System.Net.WebClient -$creds=Get-Credential -$webclient.Proxy.Credentials=$creds - $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition $vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index b6144d581..2ee87bcff 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -82,17 +82,19 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) New-Item -ItemType directory -Path $downloadDir | Out-Null } + $WC = New-Object System.Net.WebClient + $ProxyAuth = !$WC.Proxy.IsBypassed($url) + if ($ProxyAuth) + { + $ProxyCred = Get-Credential -Message "Enter credentials for Proxy Authentication" + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyAuthentication","Basic") + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyCredential",$ProxyCred) + $WC.Proxy.Credentials=$ProxyCred + } + if (($PSVersionTable.PSEdition -ne "Core") -and ($Dependency -ne "git")) # git fails with BITS { try { - $WC = New-Object System.Net.WebClient - $ProxyAuth = !$WC.Proxy.IsBypassed($url) - If($ProxyAuth){ - $ProxyCred = Get-Credential -Message "Enter credentials for Proxy Authentication" - $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyAuthentication","Basic") - $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyCredential",$ProxyCred) - } - Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop } catch [System.Exception] { @@ -106,7 +108,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if (!(Test-Path $downloadPath)) { Write-Verbose("Downloading $Dependency...") - (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath) + $WC.DownloadFile($url, $downloadPath) } } |
