aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-05-05 04:23:19 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2018-05-15 23:27:14 -0700
commit1b0682a39e1143660c3d5aa371f66591a64e8a5d (patch)
treefed8de963661a5176f70b74b91ab1cef7bf00a74 /scripts
parent52f01eefa6e1da7a9458807a1eb3d288ecd50613 (diff)
downloadvcpkg-1b0682a39e1143660c3d5aa371f66591a64e8a5d.tar.gz
vcpkg-1b0682a39e1143660c3d5aa371f66591a64e8a5d.zip
[vcpkg] Significantly reduce usage of powershell. Reduce console font switching bug
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VcpkgPowershellUtils.ps1322
-rw-r--r--scripts/addPoshVcpkgToPowershellProfile.ps17
-rw-r--r--scripts/bootstrap.ps1108
-rw-r--r--scripts/fetchTool.ps1109
-rw-r--r--scripts/findAnyMSBuildWithCppPlatformToolset.ps158
-rw-r--r--scripts/findVisualStudioInstallationInstances.ps161
-rw-r--r--scripts/getProgramFiles32bit.ps117
-rw-r--r--scripts/getProgramFilesPlatformBitness.ps117
-rw-r--r--scripts/getVisualStudioInstances.ps174
-rw-r--r--scripts/vcpkgTools.xml15
10 files changed, 174 insertions, 614 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1
index 3ea18116b..259df4acb 100644
--- a/scripts/VcpkgPowershellUtils.ps1
+++ b/scripts/VcpkgPowershellUtils.ps1
@@ -1,8 +1,3 @@
-function vcpkgHasModule([Parameter(Mandatory=$true)][string]$moduleName)
-{
- return [bool](Get-Module -ListAvailable -Name $moduleName)
-}
-
function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName)
{
if ($object -eq $null)
@@ -10,320 +5,21 @@ function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Par
return $false
}
- return [bool]($object.psobject.Properties | where { $_.Name -eq "$propertyName"})
-}
-
-function vcpkgCreateDirectoryIfNotExists([Parameter(Mandatory=$true)][string]$dirPath)
-{
- if (!(Test-Path $dirPath))
- {
- New-Item -ItemType Directory -Path $dirPath | Out-Null
- }
-}
-
-function vcpkgCreateParentDirectoryIfNotExists([Parameter(Mandatory=$true)][string]$path)
-{
- $parentDir = split-path -parent $path
- if ([string]::IsNullOrEmpty($parentDir))
- {
- return
- }
-
- if (!(Test-Path $parentDir))
- {
- New-Item -ItemType Directory -Path $parentDir | Out-Null
- }
-}
-
-function vcpkgIsDirectory([Parameter(Mandatory=$true)][string]$path)
-{
- return (Get-Item $path) -is [System.IO.DirectoryInfo]
-}
-
-function vcpkgRemoveItem([Parameter(Mandatory=$true)][string]$path)
-{
- if ([string]::IsNullOrEmpty($path))
- {
- return
- }
-
- if (Test-Path $path)
- {
- # Remove-Item -Recurse occasionally fails. This is a workaround
- if (vcpkgIsDirectory $path)
- {
- & cmd.exe /c rd /s /q $path
- }
- else
- {
- Remove-Item $path -Force
- }
- }
-}
-
-function vcpkgHasCommand([Parameter(Mandatory=$true)][string]$commandName)
-{
- return [bool](Get-Command -Name $commandName -ErrorAction SilentlyContinue)
-}
-
-function vcpkgHasCommandParameter([Parameter(Mandatory=$true)][string]$commandName, [Parameter(Mandatory=$true)][string]$parameterName)
-{
- return (Get-Command $commandName).Parameters.Keys -contains $parameterName
-}
-
-function vcpkgGetCredentials()
-{
- if (vcpkgHasCommandParameter -commandName 'Get-Credential' -parameterName 'Message')
- {
- return Get-Credential -Message "Enter credentials for Proxy Authentication"
- }
- else
- {
- Write-Host "Enter credentials for Proxy Authentication"
- return Get-Credential
- }
-}
-
-function vcpkgGetSHA512([Parameter(Mandatory=$true)][string]$filePath)
-{
- if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Utility\Get-FileHash')
- {
- Write-Verbose("Hashing with Microsoft.PowerShell.Utility\Get-FileHash")
- $hashresult = Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512 -ErrorVariable hashError
- if ($hashError)
- {
- Start-Sleep 3
- $hashresult = Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512 -ErrorVariable Stop
- }
- $hash = $hashresult.Hash
- }
- elseif(vcpkgHasCommand -commandName 'Pscx\Get-Hash')
- {
- Write-Verbose("Hashing with Pscx\Get-Hash")
- $hash = (Pscx\Get-Hash -Path $filePath -Algorithm SHA512).HashString
- }
- else
- {
- Write-Verbose("Hashing with .NET")
- $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA512")
- $fileAsByteArray = [io.File]::ReadAllBytes($filePath)
- $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray)
- $hash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_})
- }
-
- return $hash.ToLower()
+ return [bool]($object.psobject.Properties | Where-Object { $_.Name -eq "$propertyName"})
}
-function vcpkgCheckEqualFileHash( [Parameter(Mandatory=$true)][string]$url,
- [Parameter(Mandatory=$true)][string]$filePath,
- [Parameter(Mandatory=$true)][string]$expectedHash)
+function getProgramFiles32bit()
{
- $actualHash = vcpkgGetSHA512 $filePath
- if ($expectedHash -ne $actualHash)
+ $out = ${env:PROGRAMFILES(X86)}
+ if ($out -eq $null)
{
- Write-Host ("`nFile does not have expected hash:`n" +
- " url: [ $url ]`n" +
- " File path: [ $filePath ]`n" +
- " Expected hash: [ $expectedHash ]`n" +
- " Actual hash: [ $actualHash ]`n")
- throw
+ $out = ${env:PROGRAMFILES}
}
-}
-function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url,
- [Parameter(Mandatory=$true)][string]$downloadPath,
- [Parameter(Mandatory=$true)][string]$sha512)
-{
- if ($url -match "github")
+ if ($out -eq $null)
{
- if ([System.Enum]::IsDefined([Net.SecurityProtocolType], "Tls12"))
- {
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
- }
- else
- {
- Write-Warning "Github has dropped support for TLS versions prior to 1.2, which is not available on your system"
- Write-Warning "Please manually download $url to $downloadPath"
- Write-Warning "To solve this issue for future downloads, you can also install Windows Management Framework 5.1+"
- throw "Download failed"
- }
+ throw "Could not find [Program Files 32-bit]"
}
- vcpkgCreateParentDirectoryIfNotExists $downloadPath
-
- $downloadPartPath = "$downloadPath.part"
- vcpkgRemoveItem $downloadPartPath
-
- $wc = New-Object System.Net.WebClient
- if (!$wc.Proxy.IsBypassed($url))
- {
- $wc.Proxy.Credentials = vcpkgGetCredentials
- }
-
- $wc.DownloadFile($url, $downloadPartPath)
- vcpkgCheckEqualFileHash -url $url -filePath $downloadPartPath -expectedHash $sha512
- Move-Item -Path $downloadPartPath -Destination $downloadPath
-}
-
-function vcpkgDownloadFileWithAria2( [Parameter(Mandatory=$true)][string]$aria2exe,
- [Parameter(Mandatory=$true)][string]$url,
- [Parameter(Mandatory=$true)][string]$downloadPath,
- [Parameter(Mandatory=$true)][string]$sha512)
-{
- vcpkgCreateParentDirectoryIfNotExists $downloadPath
- $downloadPartPath = "$downloadPath.part"
- vcpkgRemoveItem $downloadPartPath
-
- $parentDir = split-path -parent $downloadPath
- $filename = split-path -leaf $downloadPath
-
- if ((Test-Path $url) -or ($url.StartsWith("file://"))) # if is local file
- {
- vcpkgDownloadFile $url $downloadPath $sha512
- return
- }
-
- $ec = vcpkgInvokeCommand "$aria2exe" "--dir=`"$parentDir`" --out=`"$filename.part`" $url"
- if ($ec -ne 0)
- {
- Write-Host "Could not download $url"
- throw
- }
-
- vcpkgCheckEqualFileHash -url $url -filePath $downloadPartPath -expectedHash $sha512
- Move-Item -Path $downloadPartPath -Destination $downloadPath
-}
-
-function vcpkgExtractFileWith7z([Parameter(Mandatory=$true)][string]$sevenZipExe,
- [Parameter(Mandatory=$true)][string]$archivePath,
- [Parameter(Mandatory=$true)][string]$destinationDir)
-{
- vcpkgRemoveItem $destinationDir
- $destinationPartial = "$destinationDir.partial"
- vcpkgRemoveItem $destinationPartial
- vcpkgCreateDirectoryIfNotExists $destinationPartial
- $ec = vcpkgInvokeCommand "$sevenZipExe" "x `"$archivePath`" -o`"$destinationPartial`" -y"
- if ($ec -ne 0)
- {
- Write-Host "Could not extract $archivePath"
- throw
- }
- Rename-Item -Path "$destinationPartial" -NewName $destinationDir -ErrorVariable renameResult
- if ($renameResult)
- {
- Start-Sleep 3
- Rename-Item -Path "$destinationPartial" -NewName $destinationDir -ErrorAction Stop
- }
-}
-
-function vcpkgExtractZipFile( [Parameter(Mandatory=$true)][string]$archivePath,
- [Parameter(Mandatory=$true)][string]$destinationDir)
-{
- vcpkgRemoveItem $destinationDir
- $destinationPartial = "$destinationDir.partial"
- vcpkgRemoveItem $destinationPartial
- vcpkgCreateDirectoryIfNotExists $destinationPartial
-
-
- if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Archive\Expand-Archive')
- {
- Write-Verbose("Extracting with Microsoft.PowerShell.Archive\Expand-Archive")
- Microsoft.PowerShell.Archive\Expand-Archive -path $archivePath -destinationpath $destinationPartial
- }
- elseif (vcpkgHasCommand -commandName 'Pscx\Expand-Archive')
- {
- Write-Verbose("Extracting with Pscx\Expand-Archive")
- Pscx\Expand-Archive -path $archivePath -OutputPath $destinationPartial
- }
- else
- {
- Write-Verbose("Extracting via shell")
- $shell = new-object -com shell.application
- $zip = $shell.NameSpace($(Get-Item $archivePath).fullname)
- foreach($item in $zip.items())
- {
- # Piping to Out-Null is used to block until finished
- $shell.Namespace($destinationPartial).copyhere($item) | Out-Null
- }
- }
-
- Rename-Item -Path "$destinationPartial" -NewName $destinationDir
-}
-
-function vcpkgInvokeCommand()
-{
- param ( [Parameter(Mandatory=$true)][string]$executable,
- [string]$arguments = "")
-
- Write-Verbose "Executing: ${executable} ${arguments}"
- $process = Start-Process -FilePath "`"$executable`"" -ArgumentList $arguments -PassThru -NoNewWindow
- Wait-Process -InputObject $process
- $ec = $process.ExitCode
- Write-Verbose "Execution terminated with exit code $ec."
- return $ec
-}
-
-function vcpkgInvokeCommandClean()
-{
- param ( [Parameter(Mandatory=$true)][string]$executable,
- [string]$arguments = "")
-
- Write-Verbose "Clean-Executing: ${executable} ${arguments}"
- $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
- $cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1"
- $tripleQuotes = "`"`"`""
- $argumentsWithEscapedQuotes = $arguments -replace "`"", $tripleQuotes
- $command = ". $tripleQuotes$cleanEnvScript$tripleQuotes; & $tripleQuotes$executable$tripleQuotes $argumentsWithEscapedQuotes"
- $arg = "-NoProfile", "-ExecutionPolicy Bypass", "-command $command"
-
- $process = Start-Process -FilePath powershell.exe -ArgumentList $arg -PassThru -NoNewWindow
- Wait-Process -InputObject $process
- $ec = $process.ExitCode
- Write-Verbose "Execution terminated with exit code $ec."
- return $ec
-}
-
-function vcpkgFormatElapsedTime([TimeSpan]$ts)
-{
- if ($ts.TotalHours -ge 1)
- {
- return [string]::Format( "{0:N2} h", $ts.TotalHours);
- }
-
- if ($ts.TotalMinutes -ge 1)
- {
- return [string]::Format( "{0:N2} min", $ts.TotalMinutes);
- }
-
- if ($ts.TotalSeconds -ge 1)
- {
- return [string]::Format( "{0:N2} s", $ts.TotalSeconds);
- }
-
- if ($ts.TotalMilliseconds -ge 1)
- {
- return [string]::Format( "{0:N2} ms", $ts.TotalMilliseconds);
- }
-
- throw $ts
-}
-
-function vcpkgFindFileRecursivelyUp()
-{
- param(
- [ValidateNotNullOrEmpty()]
- [Parameter(Mandatory=$true)][string]$startingDir,
- [ValidateNotNullOrEmpty()]
- [Parameter(Mandatory=$true)][string]$filename
- )
-
- $currentDir = $startingDir
-
- while (!($currentDir -eq "") -and !(Test-Path "$currentDir\$filename"))
- {
- Write-Verbose "Examining $currentDir for $filename"
- $currentDir = Split-path $currentDir -Parent
- }
- Write-Verbose "Examining $currentDir for $filename - Found"
- return $currentDir
-}
+ return $out
+} \ No newline at end of file
diff --git a/scripts/addPoshVcpkgToPowershellProfile.ps1 b/scripts/addPoshVcpkgToPowershellProfile.ps1
index dcbd2e0be..5c13a8d4a 100644
--- a/scripts/addPoshVcpkgToPowershellProfile.ps1
+++ b/scripts/addPoshVcpkgToPowershellProfile.ps1
@@ -18,10 +18,10 @@ $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
$profileEntry = "Import-Module '$scriptsDir\posh-vcpkg'"
$profilePath = $PROFILE # Implicit powershell variable
-if (!(Test-Path $profilePath))
+$profileDir = Split-Path $profilePath -Parent
+if (!(Test-Path $profileDir))
{
- $profileDir = Split-Path $profilePath -Parent
- vcpkgCreateDirectoryIfNotExists $profileDir
+ New-Item -ItemType Directory -Path $profileDir | Out-Null
}
Write-Host "`nAdding the following line to ${profilePath}:"
@@ -38,6 +38,7 @@ if ($existingImports.Count -gt 0)
return
}
+# Modifying the profile will invalidate any signatures.
# Posh-git does the following check, so we should too.
# https://github.com/dahlbyk/posh-git/blob/master/src/Utils.ps1
# If the profile script exists and is signed, then we should not modify it
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1
index c8ba503d8..41ba25746 100644
--- a/scripts/bootstrap.ps1
+++ b/scripts/bootstrap.ps1
@@ -5,35 +5,18 @@ param(
)
Set-StrictMode -Version Latest
$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
-. "$scriptsDir\VcpkgPowershellUtils.ps1"
-$vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root
-Write-Verbose("vcpkg Path " + $vcpkgRootDir)
-$gitHash = "unknownhash"
-$oldpath = $env:path
-try
-{
- [xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml"
- $toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"git`"]")
- $gitFromDownload = "$vcpkgRootDir\downloads\$($toolData.exeRelativePath)"
- $gitDir = split-path -parent $gitFromDownload
+$vcpkgRootDir = $scriptsDir
+$withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash
- $env:path += ";$gitDir"
- if (Get-Command "git" -ErrorAction SilentlyContinue)
- {
- $gitHash = git log HEAD -n 1 --format="%cd-%H" --date=short
- if ($LASTEXITCODE -ne 0)
- {
- $gitHash = "unknownhash"
- }
- }
-}
-finally
+while (!($vcpkgRootDir -eq "") -and !(Test-Path "$vcpkgRootDir\.vcpkg-root"))
{
- $env:path = $oldpath
+ Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root"
+ $vcpkgRootDir = Split-path $vcpkgRootDir -Parent
}
-Write-Verbose("Git repo version string is " + $gitHash)
+Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root - Found"
+$gitHash = "nohash"
$vcpkgSourcesPath = "$vcpkgRootDir\toolsrc"
if (!(Test-Path $vcpkgSourcesPath))
@@ -42,7 +25,58 @@ if (!(Test-Path $vcpkgSourcesPath))
return
}
-$msbuildExeWithPlatformToolset = & $scriptsDir\findAnyMSBuildWithCppPlatformToolset.ps1 $withVSPath
+function findAnyMSBuildWithCppPlatformToolset([string]$withVSPath)
+{
+ $VisualStudioInstances = & $scriptsDir\getVisualStudioInstances.ps1
+ if ($VisualStudioInstances -eq $null)
+ {
+ throw "Could not find Visual Studio. VS2015 or VS2017 (with C++) needs to be installed."
+ }
+
+ Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstances))"
+ foreach ($instanceCandidateWithEOL in $VisualStudioInstances)
+ {
+ $instanceCandidate = $instanceCandidateWithEOL -replace "<sol>::" -replace "::<eol>"
+ Write-Verbose "Inspecting: $instanceCandidate"
+ $split = $instanceCandidate -split "::"
+ # $preferenceWeight = $split[0]
+ # $releaseType = $split[1]
+ $version = $split[2]
+ $path = $split[3]
+
+ if ($withVSPath -ne "" -and $withVSPath -ne $path)
+ {
+ Write-Verbose "Skipping: $instanceCandidate"
+ continue
+ }
+
+ $majorVersion = $version.Substring(0,2);
+ if ($majorVersion -eq "15")
+ {
+ $VCFolder= "$path\VC\Tools\MSVC\"
+ if (Test-Path $VCFolder)
+ {
+ Write-Verbose "Picking: $instanceCandidate"
+ return "$path\MSBuild\15.0\Bin\MSBuild.exe", "v141"
+ }
+ }
+
+ if ($majorVersion -eq "14")
+ {
+ $clExe= "$path\VC\bin\cl.exe"
+ if (Test-Path $clExe)
+ {
+ Write-Verbose "Picking: $instanceCandidate"
+ $programFilesPath = getProgramFiles32bit
+ return "$programFilesPath\MSBuild\14.0\Bin\MSBuild.exe", "v140"
+ }
+ }
+ }
+
+ throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed."
+}
+
+$msbuildExeWithPlatformToolset = findAnyMSBuildWithCppPlatformToolset $withVSPath
$msbuildExe = $msbuildExeWithPlatformToolset[0]
$platformToolset = $msbuildExeWithPlatformToolset[1]
$windowsSDK = & $scriptsDir\getWindowsSDK.ps1
@@ -54,10 +88,33 @@ $arguments = (
"/p:Platform=x86",
"/p:PlatformToolset=$platformToolset",
"/p:TargetPlatformVersion=$windowsSDK",
+"/verbosity:minimal",
"/m",
+"/nologo",
"`"$vcpkgSourcesPath\dirs.proj`"") -join " "
+function vcpkgInvokeCommandClean()
+{
+ param ( [Parameter(Mandatory=$true)][string]$executable,
+ [string]$arguments = "")
+
+ Write-Verbose "Clean-Executing: ${executable} ${arguments}"
+ $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
+ $cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1"
+ $tripleQuotes = "`"`"`""
+ $argumentsWithEscapedQuotes = $arguments -replace "`"", $tripleQuotes
+ $command = ". $tripleQuotes$cleanEnvScript$tripleQuotes; & $tripleQuotes$executable$tripleQuotes $argumentsWithEscapedQuotes"
+ $arg = "-NoProfile", "-ExecutionPolicy Bypass", "-command $command"
+
+ $process = Start-Process -FilePath powershell.exe -ArgumentList $arg -PassThru -NoNewWindow
+ Wait-Process -InputObject $process
+ $ec = $process.ExitCode
+ Write-Verbose "Execution terminated with exit code $ec."
+ return $ec
+}
+
# vcpkgInvokeCommandClean cmd "/c echo %PATH%"
+Write-Host "`nBuilding vcpkg.exe ...`n"
$ec = vcpkgInvokeCommandClean $msbuildExe $arguments
if ($ec -ne 0)
@@ -65,6 +122,7 @@ if ($ec -ne 0)
Write-Error "Building vcpkg.exe failed. Please ensure you have installed Visual Studio with the Desktop C++ workload and the Windows SDK for Desktop C++."
return
}
+Write-Host "`nBuilding vcpkg.exe... done.`n"
Write-Verbose("Placing vcpkg.exe in the correct location")
diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1
deleted file mode 100644
index eca405b62..000000000
--- a/scripts/fetchTool.ps1
+++ /dev/null
@@ -1,109 +0,0 @@
-[CmdletBinding()]
-param(
- [Parameter(Mandatory=$true)][string]$tool
-)
-
-Set-StrictMode -Version Latest
-
-$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
-. "$scriptsDir\VcpkgPowershellUtils.ps1"
-
-Write-Verbose "Fetching tool: $tool"
-$vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root
-
-$downloadsDir = "$vcpkgRootDir\downloads"
-vcpkgCreateDirectoryIfNotExists $downloadsDir
-$downloadsDir = Resolve-Path $downloadsDir
-
-function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool)
-{
- $tool = $tool.toLower()
-
- [xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml"
- $toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"$tool`"]") # Case-sensitive!
-
- if ($toolData -eq $null)
- {
- throw "Unknown tool $tool"
- }
-
- $toolPath="$downloadsDir\tools\$tool-$($toolData.version)-windows"
- $exePath = "$toolPath\$($toolData.exeRelativePath)"
-
- if (Test-Path $exePath)
- {
- return $exePath
- }
-
- $isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveName"
- if ($isArchive)
- {
- $downloadPath = "$downloadsDir\$($toolData.archiveName)"
- }
- else
- {
- $downloadPath = "$toolPath\$($toolData.exeRelativePath)"
- }
-
- [String]$url = $toolData.url
- if (!(Test-Path $downloadPath))
- {
- Write-Host "Downloading $tool..."
-
- # Download aria2 with .NET. aria2 will be used to download everything else.
- if ($tool -eq "aria2")
- {
- vcpkgDownloadFile $url $downloadPath $toolData.sha512
- }
- else
- {
- $aria2exe = fetchToolInternal "aria2"
- vcpkgDownloadFileWithAria2 $aria2exe $url $downloadPath $toolData.sha512
- }
-
- Write-Host "Downloading $tool... done."
- }
- else
- {
- vcpkgCheckEqualFileHash -url $url -filePath $downloadPath -expectedHash $toolData.sha512
- }
-
- if ($isArchive)
- {
- Write-Host "Extracting $tool..."
- # Extract 7zip920 with shell because we need it to extract 7zip
- # Extract aria2 with shell because we need it to download 7zip
- if ($tool -eq "7zip920" -or $tool -eq "aria2")
- {
- vcpkgExtractZipFile -ArchivePath $downloadPath -DestinationDir $toolPath
- }
- elseif ($tool -eq "7zip")
- {
- $sevenZip920 = fetchToolInternal "7zip920"
- $ec = vcpkgInvokeCommand "$sevenZip920" "x `"$downloadPath`" -o`"$toolPath`" -y"
- if ($ec -ne 0)
- {
- Write-Host "Could not extract $downloadPath"
- throw
- }
- }
- else
- {
- $sevenZipExe = fetchToolInternal "7zip"
- vcpkgExtractFileWith7z -sevenZipExe "$sevenZipExe" -ArchivePath $downloadPath -DestinationDir $toolPath
- }
- Write-Host "Extracting $tool... done."
- }
-
- if (-not (Test-Path $exePath))
- {
- Write-Error "Could not detect or download $tool"
- throw
- }
-
- return $exePath
-}
-
-$path = fetchToolInternal $tool
-Write-Verbose "Fetching tool: $tool. Done."
-return "<sol>::$path::<eol>"
diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1
deleted file mode 100644
index d7fd24e24..000000000
--- a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1
+++ /dev/null
@@ -1,58 +0,0 @@
-[CmdletBinding()]
-param(
- [Parameter(Mandatory=$False)]
- [string]$withVSPath = ""
-)
-
-Set-StrictMode -Version Latest
-$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
-
-$withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash
-
-$VisualStudioInstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1
-if ($VisualStudioInstallationInstances -eq $null)
-{
- throw "Could not find Visual Studio. VS2015 or VS2017 (with C++) needs to be installed."
-}
-
-Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))"
-foreach ($instanceCandidateWithEOL in $VisualStudioInstallationInstances)
-{
- $instanceCandidate = $instanceCandidateWithEOL -replace "<sol>::" -replace "::<eol>"
- Write-Verbose "Inspecting: $instanceCandidate"
- $split = $instanceCandidate -split "::"
- # $preferenceWeight = $split[0]
- # $releaseType = $split[1]
- $version = $split[2]
- $path = $split[3]
-
- if ($withVSPath -ne "" -and $withVSPath -ne $path)
- {
- Write-Verbose "Skipping: $instanceCandidate"
- continue
- }
-
- $majorVersion = $version.Substring(0,2);
- if ($majorVersion -eq "15")
- {
- $VCFolder= "$path\VC\Tools\MSVC\"
- if (Test-Path $VCFolder)
- {
- Write-Verbose "Picking: $instanceCandidate"
- return "$path\MSBuild\15.0\Bin\MSBuild.exe", "v141"
- }
- }
-
- if ($majorVersion -eq "14")
- {
- $clExe= "$path\VC\bin\cl.exe"
- if (Test-Path $clExe)
- {
- Write-Verbose "Picking: $instanceCandidate"
- $programFilesPath = & $scriptsDir\getProgramFiles32bit.ps1
- return "$programFilesPath\MSBuild\14.0\Bin\MSBuild.exe", "v140"
- }
- }
-}
-
-throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed." \ No newline at end of file
diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1
deleted file mode 100644
index cb51c345d..000000000
--- a/scripts/findVisualStudioInstallationInstances.ps1
+++ /dev/null
@@ -1,61 +0,0 @@
-[CmdletBinding()]
-param(
-
-)
-Set-StrictMode -Version Latest
-$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
-. "$scriptsDir\VcpkgPowershellUtils.ps1"
-
-$vswhereExe = (& $scriptsDir\fetchTool.ps1 "vswhere") -replace "<sol>::" -replace "::<eol>"
-
-$output = & $vswhereExe -prerelease -legacy -products * -format xml
-[xml]$asXml = $output
-
-$results = New-Object System.Collections.ArrayList
-foreach ($instance in $asXml.instances.instance)
-{
- $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
- $installationVersion = $instance.InstallationVersion
-
- $isPrerelease = -7
- if (vcpkgHasProperty -object $instance -propertyName "isPrerelease")
- {
- $isPrerelease = $instance.isPrerelease
- }
-
- if ($isPrerelease -eq 0)
- {
- $releaseType = "PreferenceWeight3::StableRelease"
- }
- elseif ($isPrerelease -eq 1)
- {
- $releaseType = "PreferenceWeight2::PreRelease"
- }
- else
- {
- $releaseType = "PreferenceWeight1::Legacy"
- }
-
- # Placed like that for easy sorting according to preference
- $results.Add("<sol>::${releaseType}::${installationVersion}::${installationPath}::<eol>") > $null
-}
-
-# If nothing is found, attempt to find VS2015 Build Tools (not detected by vswhere.exe)
-if ($results.Count -eq 0)
-{
- $programFiles = & $scriptsDir\getProgramFiles32bit.ps1
- $installationPath = "$programFiles\Microsoft Visual Studio 14.0"
- $clExe = "$installationPath\VC\bin\cl.exe"
- $vcvarsallbat = "$installationPath\VC\vcvarsall.bat"
-
- if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat))
- {
- return "<sol>::PreferenceWeight1::Legacy::14.0::$installationPath::<eol>"
- }
-}
-
-
-$results.Sort()
-$results.Reverse()
-
-return $results \ No newline at end of file
diff --git a/scripts/getProgramFiles32bit.ps1 b/scripts/getProgramFiles32bit.ps1
deleted file mode 100644
index 6b71915b1..000000000
--- a/scripts/getProgramFiles32bit.ps1
+++ /dev/null
@@ -1,17 +0,0 @@
-[CmdletBinding()]
-param(
-
-)
-
-$out = ${env:PROGRAMFILES(X86)}
-if ($out -eq $null)
-{
- $out = ${env:PROGRAMFILES}
-}
-
-if ($out -eq $null)
-{
- throw "Could not find [Program Files 32-bit]"
-}
-
-return $out \ No newline at end of file
diff --git a/scripts/getProgramFilesPlatformBitness.ps1 b/scripts/getProgramFilesPlatformBitness.ps1
deleted file mode 100644
index 2be4c1137..000000000
--- a/scripts/getProgramFilesPlatformBitness.ps1
+++ /dev/null
@@ -1,17 +0,0 @@
-[CmdletBinding()]
-param(
-
-)
-
-$out = ${env:ProgramW6432}
-if ($out -eq $null)
-{
- $out = ${env:PROGRAMFILES}
-}
-
-if ($out -eq $null)
-{
- throw "Could not find [Program Files Platform Bitness]"
-}
-
-return $out \ No newline at end of file
diff --git a/scripts/getVisualStudioInstances.ps1 b/scripts/getVisualStudioInstances.ps1
new file mode 100644
index 000000000..83b0b8ebd
--- /dev/null
+++ b/scripts/getVisualStudioInstances.ps1
@@ -0,0 +1,74 @@
+[CmdletBinding()]
+param(
+
+)
+Set-StrictMode -Version Latest
+$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
+. "$scriptsDir\VcpkgPowershellUtils.ps1"
+
+$programFiles = getProgramFiles32bit
+
+$results = New-Object System.Collections.ArrayList
+
+$vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe"
+
+if (Test-Path $vswhereExe)
+{
+ $output = & $vswhereExe -prerelease -legacy -products * -format xml
+ [xml]$asXml = $output
+
+ foreach ($instance in $asXml.instances.instance)
+ {
+ $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
+ $installationVersion = $instance.InstallationVersion
+
+ $isPrerelease = -7
+ if (vcpkgHasProperty -object $instance -propertyName "isPrerelease")
+ {
+ $isPrerelease = $instance.isPrerelease
+ }
+
+ if ($isPrerelease -eq 0)
+ {
+ $releaseType = "PreferenceWeight3::StableRelease"
+ }
+ elseif ($isPrerelease -eq 1)
+ {
+ $releaseType = "PreferenceWeight2::PreRelease"
+ }
+ else
+ {
+ $releaseType = "PreferenceWeight1::Legacy"
+ }
+
+ # Placed like that for easy sorting according to preference
+ $results.Add("<sol>::${releaseType}::${installationVersion}::${installationPath}::<eol>") > $null
+ }
+}
+else
+{
+ Write-Verbose "Could not locate vswhere at $vswhereExe"
+}
+
+$installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools")
+$clExe = "$installationPath\VC\bin\cl.exe"
+$vcvarsallbat = "$installationPath\VC\vcvarsall.bat"
+
+if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat))
+{
+ $results.Add("<sol>::PreferenceWeight1::Legacy::14.0::$installationPath::<eol>") > $null
+}
+
+$installationPath = "$programFiles\Microsoft Visual Studio 14.0"
+$clExe = "$installationPath\VC\bin\cl.exe"
+$vcvarsallbat = "$installationPath\VC\vcvarsall.bat"
+
+if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat))
+{
+ $results.Add("<sol>::PreferenceWeight1::Legacy::14.0::$installationPath::<eol>") > $null
+}
+
+$results.Sort()
+$results.Reverse()
+
+return $results
diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml
index 1f17102d2..9d5487577 100644
--- a/scripts/vcpkgTools.xml
+++ b/scripts/vcpkgTools.xml
@@ -61,17 +61,10 @@
</tool>
<tool name="7zip" os="windows">
<version>18.01.0</version>
- <exeRelativePath>7za.exe</exeRelativePath>
- <url>https://www.7-zip.org/a/7z1801-extra.7z</url>
- <sha512>9133fc551d76515e37fdd4dd8c1e28d464aea493548246b44565a42bba46715764f41f9cfa14d470d298c3a6e9829d200f8be5168cb67cf8f23d8042fca833bc</sha512>
- <archiveName>7z1801-extra.7z</archiveName>
- </tool>
- <tool name="7zip920" os="windows">
- <version>9.20.0</version>
- <exeRelativePath>7za.exe</exeRelativePath>
- <url>https://www.7-zip.org/a/7za920.zip</url>
- <sha512>84e830c91a0e8ae499cc4814080da6569d8a6acbddc585c8b62abc86c809793aeb669b0a741063a379fd281ade85f120bc27efeb67d63bf961be893eec8bc3b3</sha512>
- <archiveName>7za920.zip</archiveName>
+ <exeRelativePath>7-Zip.CommandLine.18.1.0\tools\7za.exe</exeRelativePath>
+ <url>https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0</url>
+ <sha512>8c75314102e68d2b2347d592f8e3eb05812e1ebb525decbac472231633753f1d4ca31c8e6881a36144a8da26b2571305b3ae3f4e2b85fc4a290aeda63d1a13b8</sha512>
+ <archiveName>7-zip.commandline.18.1.0.nupkg</archiveName>
</tool>
<tool name="aria2" os="windows">
<version>18.01.0</version>