aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-10-17 13:58:36 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-10-17 13:58:36 -0700
commitffd91c0c1d071378d383ad94ba915e2c10dff06b (patch)
tree488c1004fdaec5ac576f2fdf078f7bf5c40ee566 /scripts
parentd6d5540cc54c5d3dcbb43bdc6d0fd5b2d6271d21 (diff)
downloadvcpkg-ffd91c0c1d071378d383ad94ba915e2c10dff06b.tar.gz
vcpkg-ffd91c0c1d071378d383ad94ba915e2c10dff06b.zip
[fetchDependency] Call Get-FileHash if available, otherwise fallback
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fetchDependency.ps110
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index d2e2b89fd..e8c66c84d 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -194,17 +194,17 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion
#calculating the hash
- if ($PSVersionTable.PSEdition -ne "Core")
+ if (Test-Command -commandName 'Get-FileHash')
+ {
+ $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
+ }
+ else
{
$hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256")
$fileAsByteArray = [io.File]::ReadAllBytes($downloadPath)
$hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray)
$downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_})
}
- else
- {
- $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
- }
if ($expectedDownloadedFileHash -ne $downloadedFileHash)
{