aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-05-23 11:53:20 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-05-23 11:53:20 -0700
commit5ba2f0d81cf9ad13d544606608f314230a0db283 (patch)
tree8460bc44dbcfc621e9e0305a814da380a41a1546 /scripts
parent932f0f0657767c26687dcad81311d4badc56348b (diff)
downloadvcpkg-5ba2f0d81cf9ad13d544606608f314230a0db283.tar.gz
vcpkg-5ba2f0d81cf9ad13d544606608f314230a0db283.zip
scripts/fetchDependency.ps1: Retain previous code for hashing to support Win7
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fetchDependency.ps116
1 files changed, 13 insertions, 3 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index bbc027861..6c2e85b60 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -10,7 +10,7 @@ $downloadPromptOverride_DO_NOT_PROMPT = 1
$downloadPromptOverride_ALWAYS_PROMPT = 2
if ($PSVersionTable.PSEdition -eq "Desktop") {
- Import-Module BitsTransfer -Verbose:$false
+ Import-Module BitsTransfer -Verbose:$false
}
Write-Verbose "Fetching dependency: $Dependency"
@@ -197,8 +197,18 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion
#calculating the hash
- $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
-
+ if ($PSVersionTable.PSEdition -eq "Desktop")
+ {
+ $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256")
+ $fileAsByteArray = [io.File]::ReadAllBytes($downloadPath)
+ $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray)
+ $downloadedFileHash = -Join ($hashByteArray | ForEach {"{0:x2}" -f $_})
+ }
+ else
+ {
+ $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
+ }
+
if ($expectedDownloadedFileHash -ne $downloadedFileHash)
{
throw [System.IO.FileNotFoundException] ("Mismatching hash of the downloaded " + $Dependency)