diff options
| author | Alexander Karatarakis <alex@karatarakis.com> | 2017-05-23 11:59:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-23 11:59:25 -0700 |
| commit | 9db43574c9bbb251a51eda8197cc269e8defab26 (patch) | |
| tree | 8393ccb9582a37ae63bce59c1b958eced4b6ed50 /scripts | |
| parent | dfaa7a831c914447cb9413bc82bd3ea2ee72594b (diff) | |
| parent | 5ba2f0d81cf9ad13d544606608f314230a0db283 (diff) | |
| download | vcpkg-9db43574c9bbb251a51eda8197cc269e8defab26.tar.gz vcpkg-9db43574c9bbb251a51eda8197cc269e8defab26.zip | |
Merge pull request #1141 from Mixaill/pscore-bootstrap
scripts/fetchDependency.ps1: fix vcpkg boostrapping with Powershell Core
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/fetchDependency.ps1 | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 98144bffa..6c2e85b60 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,10 +197,17 @@ 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 $_}) + 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) { |
