2016-09-19 03:50:08 +00:00
[ CmdletBinding ( ) ]
param (
2017-11-10 04:09:04 +00:00
[ ValidateNotNullOrEmpty ( ) ] [ string ] $disableMetrics = " 0 " ,
2017-11-10 05:41:16 +00:00
[ Parameter ( Mandatory = $False ) ] [ string ] $withVSPath = " "
2016-09-19 03:50:08 +00:00
)
2016-09-20 01:46:02 +00:00
$scriptsDir = split-path -parent $MyInvocation . MyCommand . Definition
$vcpkgRootDir = & $scriptsDir \ findFileRecursivelyUp . ps1 $scriptsDir . vcpkg-root
2017-08-26 06:20:57 +00:00
Write-Verbose ( " vcpkg Path " + $vcpkgRootDir )
2016-09-19 03:50:08 +00:00
2016-11-22 02:10:21 +00:00
$gitHash = " unknownhash "
2017-08-26 06:25:41 +00:00
$oldpath = $env:path
try
2016-11-22 02:10:21 +00:00
{
2017-11-01 00:30:29 +00:00
$env:path + = " ; $vcpkgRootDir \downloads\MinGit-2.15.0-32-bit\cmd "
2017-08-29 00:33:03 +00:00
if ( Get-Command " git " -ErrorAction SilentlyContinue )
2017-08-26 06:20:57 +00:00
{
2017-08-26 06:25:41 +00:00
$gitHash = git log HEAD -n 1 - -format = " %cd-%H " - -date = short
if ( $LASTEXITCODE -ne 0 )
{
$gitHash = " unknownhash "
}
2017-08-26 06:20:57 +00:00
}
2016-11-22 02:10:21 +00:00
}
2017-08-26 06:25:41 +00:00
finally
{
$env:path = $oldpath
}
2017-08-26 06:20:57 +00:00
Write-Verbose ( " Git repo version string is " + $gitHash )
2016-09-20 01:46:02 +00:00
$vcpkgSourcesPath = " $vcpkgRootDir \toolsrc "
2016-09-19 03:50:08 +00:00
if ( ! ( Test-Path $vcpkgSourcesPath ) )
{
2017-11-01 06:41:24 +00:00
Write-Error " Unable to determine vcpkg sources directory. ' $vcpkgSourcesPath ' does not exist. "
return
2016-09-19 03:50:08 +00:00
}
2017-08-26 06:25:41 +00:00
try
{
2017-11-10 05:42:36 +00:00
Push-Location $vcpkgSourcesPath
2017-11-10 05:41:16 +00:00
$msbuildExeWithPlatformToolset = & $scriptsDir \ findAnyMSBuildWithCppPlatformToolset . ps1 $withVSPath
2017-01-23 20:54:33 +00:00
$msbuildExe = $msbuildExeWithPlatformToolset [ 0 ]
$platformToolset = $msbuildExeWithPlatformToolset [ 1 ]
2017-02-22 01:42:39 +00:00
$windowsSDK = & $scriptsDir \ getWindowsSDK . ps1
& $msbuildExe " /p:VCPKG_VERSION=- $gitHash " " /p:DISABLE_METRICS= $disableMetrics " / p: Configuration = Release / p: Platform = x86 / p: PlatformToolset = $platformToolset / p: TargetPlatformVersion = $windowsSDK / m dirs . proj
2017-11-01 06:41:24 +00:00
if ( $LASTEXITCODE -ne 0 )
{
2017-12-01 00:43:41 +00:00
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++. "
2017-11-01 06:41:24 +00:00
return
}
2016-09-19 03:50:08 +00:00
Write-Verbose ( " Placing vcpkg.exe in the correct location " )
2016-09-20 01:46:02 +00:00
Copy-Item $vcpkgSourcesPath \ Release \ vcpkg . exe $vcpkgRootDir \ vcpkg . exe | Out-Null
Copy-Item $vcpkgSourcesPath \ Release \ vcpkgmetricsuploader . exe $vcpkgRootDir \ scripts \ vcpkgmetricsuploader . exe | Out-Null
2016-09-19 03:50:08 +00:00
}
2017-08-26 06:25:41 +00:00
finally
{
2017-11-10 05:42:36 +00:00
Pop-Location
2016-09-19 03:50:08 +00:00
}