diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-08-15 14:41:23 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-08-15 14:41:23 -0700 |
| commit | f4d11d7c9ea98007af88684db12de351b83bd976 (patch) | |
| tree | 6bee2241388aaf0e0d191fe30317de16a321c09f /scripts/fetchDependency.ps1 | |
| parent | 3e0a1ddf7eb8273d8a0df8001569e7c1b2857d71 (diff) | |
| download | vcpkg-f4d11d7c9ea98007af88684db12de351b83bd976.tar.gz vcpkg-f4d11d7c9ea98007af88684db12de351b83bd976.zip | |
Remove download prompts for cmake/git
The prompts were causing a lot of issues for users and especially CI builds
Diffstat (limited to 'scripts/fetchDependency.ps1')
| -rw-r--r-- | scripts/fetchDependency.ps1 | 53 |
1 files changed, 3 insertions, 50 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index d142f57fe..5eb0cc0db 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -1,14 +1,8 @@ [CmdletBinding()] param( - [string]$Dependency, - [ValidateNotNullOrEmpty()] - [string]$downloadPromptOverride = "0" + [string]$Dependency ) -$downloadPromptOverride_NO_OVERRIDE= 0 -$downloadPromptOverride_DO_NOT_PROMPT = 1 -$downloadPromptOverride_ALWAYS_PROMPT = 2 - if ($PSVersionTable.PSEdition -ne "Core") { Import-Module BitsTransfer -Verbose:$false } @@ -22,38 +16,6 @@ $downloadsDir = "$vcpkgRootDir\downloads" function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { - function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription, [string]$downloadPromptOverride) - { - $do_not_prompt = ($downloadPromptOverride -eq $downloadPromptOverride_DO_NOT_PROMPT) -Or - (Test-Path "$downloadsDir\AlwaysAllowEverything") -Or - (Test-Path "$downloadsDir\AlwaysAllowDownloads") - - if (($downloadPromptOverride -ne $downloadPromptOverride_ALWAYS_PROMPT) -And $do_not_prompt) - { - return $true - } - - $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", $yesDescription - $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", $noDescription - $AlwaysAllowDownloads = New-Object System.Management.Automation.Host.ChoiceDescription "&Always Allow Downloads", ($yesDescription + "(Future download prompts will not be displayed)") - - $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no, $AlwaysAllowDownloads) - $result = $host.ui.PromptForChoice($title, $message, $options, 0) - - switch ($result) - { - 0 {return $true} - 1 {return $false} - 2 { - New-Item "$downloadsDir\AlwaysAllowDownloads" -type file -force | Out-Null - return $true - } - } - - throw "Unexpected result" - } - - function performDownload( [Parameter(Mandatory=$true)][string]$Dependency, [Parameter(Mandatory=$true)][string]$url, [Parameter(Mandatory=$true)][string]$downloadDir, @@ -66,16 +28,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) return } - $title = "Download " + $Dependency - $message = ("No suitable version of " + $Dependency + " was found (requires $requiredVersion or higher). Download portable version?") - $yesDescription = "Downloads " + $Dependency + " v" + $downloadVersion +" app-locally." - $noDescription = "Does not download " + $Dependency + "." - - $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription $downloadPromptOverride - if (!$userAllowedDownload) - { - throw [System.IO.FileNotFoundException] ("Could not detect suitable version of " + $Dependency + " and download not allowed") - } + Write-Host "A suitable version of $Dependency was not found (required v$requiredVersion). Downloading portable $Dependency v$downloadVersion..." if (!(Test-Path $downloadDir)) { @@ -202,7 +155,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256") $fileAsByteArray = [io.File]::ReadAllBytes($downloadPath) $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray) - $downloadedFileHash = -Join ($hashByteArray | ForEach {"{0:x2}" -f $_}) + $downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_}) } else { |
