mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-19 02:13:03 +08:00
scripts/fetchDependency.ps1: fix vcpkg boostrapping with Powershell Core
This commit is contained in:
parent
fb689bd13d
commit
932f0f0657
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user