From 932f0f0657767c26687dcad81311d4badc56348b Mon Sep 17 00:00:00 2001 From: Mikhail Paulyshka Date: Mon, 22 May 2017 23:57:37 +0300 Subject: scripts/fetchDependency.ps1: fix vcpkg boostrapping with Powershell Core --- scripts/fetchDependency.ps1 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 98144bffa..bbc027861 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -9,7 +9,9 @@ $downloadPromptOverride_NO_OVERRIDE= 0 $downloadPromptOverride_DO_NOT_PROMPT = 1 $downloadPromptOverride_ALWAYS_PROMPT = 2 -Import-Module BitsTransfer -Verbose:$false +if ($PSVersionTable.PSEdition -eq "Desktop") { + Import-Module BitsTransfer -Verbose:$false +} Write-Verbose "Fetching dependency: $Dependency" @@ -80,7 +82,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) New-Item -ItemType directory -Path $downloadDir | Out-Null } - if ($Dependency -ne "git") # git fails with BITS + if (($PSVersionTable.PSEdition -eq "Desktop") -and ($Dependency -ne "git")) # git fails with BITS { try { $WC = New-Object System.Net.WebClient @@ -195,11 +197,8 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion #calculating the hash - $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256") - $fileAsByteArray = [io.File]::ReadAllBytes($downloadPath) - $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray) - $downloadedFileHash = -Join ($hashByteArray | ForEach {"{0:x2}" -f $_}) - + $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash + if ($expectedDownloadedFileHash -ne $downloadedFileHash) { throw [System.IO.FileNotFoundException] ("Mismatching hash of the downloaded " + $Dependency) -- cgit v1.2.3 From 5ba2f0d81cf9ad13d544606608f314230a0db283 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 23 May 2017 11:53:20 -0700 Subject: scripts/fetchDependency.ps1: Retain previous code for hashing to support Win7 --- scripts/fetchDependency.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'scripts') 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) -- cgit v1.2.3