aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
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)