aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-10-12 10:54:20 -0700
committerGitHub <noreply@github.com>2017-10-12 10:54:20 -0700
commit94ec090235b96881e57a37935c7e73da7c92c9fc (patch)
tree7c00c702157c6f9d93fe0b2b4f11d05aa2d8f914 /scripts
parent0179bc051ea1c5d60547b283e8e8c60472b1d2e7 (diff)
parent9ddc98988fb8d7c886963fa7568395ecd5785eaa (diff)
downloadvcpkg-94ec090235b96881e57a37935c7e73da7c92c9fc.tar.gz
vcpkg-94ec090235b96881e57a37935c7e73da7c92c9fc.zip
Merge pull request #1920 from frederich/Bug_1130
Get proxy credentials behind web proxy
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fetchDependency.ps120
1 files changed, 11 insertions, 9 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index bc58f4436..773ebeac4 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -36,17 +36,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] {
@@ -60,7 +62,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)
}
}