aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-02-12 22:18:09 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-02-16 19:21:55 -0800
commitcf537a2623efa6c892afce3301ffb98ad46a6b1e (patch)
treefac2deb508551a89bf20840555cbb5bb5e97d4a8 /scripts
parentd36b292ae2b7bfb92d7c03d6aa44bb2a74311c36 (diff)
downloadvcpkg-cf537a2623efa6c892afce3301ffb98ad46a6b1e.tar.gz
vcpkg-cf537a2623efa6c892afce3301ffb98ad46a6b1e.zip
[vcpkg] Use the Registry to find VS2015
Diffstat (limited to 'scripts')
-rw-r--r--scripts/findAnyMSBuildWithCppPlatformToolset.ps158
1 files changed, 42 insertions, 16 deletions
diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1
index d160aea12..15234a2f8 100644
--- a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1
+++ b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1
@@ -1,34 +1,60 @@
[CmdletBinding()]
param(
+ [Parameter(Mandatory=$False)]
+ [switch]$DisableVS2017 = $False,
+ [Parameter(Mandatory=$False)]
+ [switch]$DisableVS2015 = $False
)
$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
-# VS2017
-$VisualStudio2017InstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1
-foreach ($instance in $VisualStudio2017InstallationInstances)
+if (-not $DisableVS2017)
{
- $VCFolder= "$instance\VC\Tools\MSVC\"
-
- if (Test-Path $VCFolder)
+ # VS2017
+ $VisualStudio2017InstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1
+ foreach ($instance in $VisualStudio2017InstallationInstances)
{
- return "$instance\MSBuild\15.0\Bin\MSBuild.exe","v141"
+ $VCFolder= "$instance\VC\Tools\MSVC\"
+
+ if (Test-Path $VCFolder)
+ {
+ return "$instance\MSBuild\15.0\Bin\MSBuild.exe","v141"
+ }
}
}
-# VS2015
-$programFiles32 = & $scriptsDir\getProgramFiles32bit.ps1
-$programFilesP = & $scriptsDir\getProgramFilesPlatformBitness.ps1
-$CandidateProgramFiles = $programFiles32, $programFilesP
-foreach ($ProgramFiles in $CandidateProgramFiles)
+if (-not $DisableVS2015)
{
- $clExe= "$ProgramFiles\Microsoft Visual Studio 14.0\\VC\bin\cl.exe"
+ # Try to locate VS2015 through the Registry
+ try
+ {
+ # First ensure the compiler was installed (optional in 2015)
+ # In 64-bit systems, this is under the Wow6432Node.
+ try
+ {
+ $VS14InstallDir = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\visualstudio\14.0 InstallDir -erroraction Stop | % InstallDir)
+ Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\visualstudio\14.0 - Found"
+ }
+ catch
+ {
+ $VS14InstallDir = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\visualstudio\14.0 InstallDir -erroraction Stop | % InstallDir)
+ Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\visualstudio\14.0 - Found"
+ }
+ if (!(Test-Path "${VS14InstallDir}..\..\VC\bin\cl.exe")) { throw }
+ Write-Verbose "${VS14InstallDir}..\..\VC\bin\cl.exe - Found"
- if (Test-Path $clExe)
+ $MSBuild14 = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\msbuild\toolsversions\14.0 MSBuildToolsPath -erroraction Stop | % MSBuildToolsPath)
+ Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\msbuild\toolsversions\14.0 - Found"
+ if (!(Test-Path "${MSBuild14}MSBuild.exe")) { throw }
+ Write-Verbose "${MSBuild14}MSBuild.exe - Found"
+
+ return "${MSBuild14}MSBuild.exe","v140"
+ }
+ catch
{
- return "$ProgramFiles\MSBuild\14.0\Bin\MSBuild.exe","v140"
+ Write-Verbose "Unable to locate a VS2015 installation with C++ support"
}
}
-throw "Could not find MSBuild with C++ support. VS2015 or above with C++ support need to be installed." \ No newline at end of file
+throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed." \ No newline at end of file