2016-09-18 20:50:08 -07:00
[ CmdletBinding ( ) ]
param (
2018-06-12 17:12:33 -07:00
$badParam ,
2018-06-13 11:21:12 -07:00
[ Parameter ( Mandatory = $False ) ] [ switch ] $win64 = $false ,
2018-06-08 13:31:57 -07:00
[ Parameter ( Mandatory = $False ) ] [ string ] $withVSPath = " " ,
2021-02-04 10:15:44 -08:00
[ Parameter ( Mandatory = $False ) ] [ string ] $withWinSDK = " " ,
[ Parameter ( Mandatory = $False ) ] [ switch ] $disableMetrics = $false
2016-09-18 20:50:08 -07:00
)
2018-02-28 18:44:57 -08:00
Set-StrictMode -Version Latest
2018-06-12 17:12:33 -07:00
# Powershell2-compatible way of forcing named-parameters
if ( $badParam )
{
if ( $disableMetrics -and $badParam -eq " 1 " )
{
2021-02-04 10:15:44 -08:00
Write-Warning " 'disableMetrics 1' is deprecated, please change to 'disableMetrics' (without '1'). "
2018-06-12 17:12:33 -07:00
}
else
{
2021-02-04 10:15:44 -08:00
throw " Only named parameters are allowed. "
2018-06-12 17:12:33 -07:00
}
}
2021-02-04 10:15:44 -08:00
if ( $win64 )
2018-05-19 17:54:50 -07:00
{
2021-02-04 10:15:44 -08:00
Write-Warning " -win64 no longer has any effect; ignored. "
2018-05-19 17:54:50 -07:00
}
2021-02-04 10:15:44 -08:00
if ( -Not [ string ] :: IsNullOrWhiteSpace ( $withVSPath ) )
2018-05-19 17:54:50 -07:00
{
2021-02-04 10:15:44 -08:00
Write-Warning " -withVSPath no longer has any effect; ignored. "
}
2018-05-19 17:54:50 -07:00
2021-02-04 10:15:44 -08:00
if ( -Not [ string ] :: IsNullOrWhiteSpace ( $withWinSDK ) )
{
Write-Warning " -withWinSDK no longer has any effect; ignored. "
2018-05-19 17:54:50 -07:00
}
2018-02-22 19:56:08 -08:00
2021-02-04 10:15:44 -08:00
$scriptsDir = split-path -parent $script:MyInvocation . MyCommand . Definition
2018-05-19 19:38:45 -07:00
$vcpkgRootDir = $scriptsDir
2018-05-05 04:23:19 -07:00
while ( ! ( $vcpkgRootDir -eq " " ) -and ! ( Test-Path " $vcpkgRootDir \.vcpkg-root " ) )
2017-08-25 23:25:41 -07:00
{
2018-05-05 04:23:19 -07:00
Write-Verbose " Examining $vcpkgRootDir for .vcpkg-root "
$vcpkgRootDir = Split-path $vcpkgRootDir -Parent
2017-08-25 23:25:41 -07:00
}
2018-05-19 17:50:51 -07:00
2021-02-04 10:15:44 -08:00
Write-Verbose " Examining $vcpkgRootDir for .vcpkg-root - Found "
2018-05-05 04:23:19 -07:00
2023-07-25 20:35:26 -07:00
# Read the vcpkg-tool config file to determine what release to download
$Config = ConvertFrom-StringData ( Get-Content " $PSScriptRoot \vcpkg-tool-metadata.txt " -Raw )
$versionDate = $Config . VCPKG_TOOL_RELEASE_TAG
2022-01-21 14:10:58 -05:00
if ( $env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_IDENTIFIER -match " ARMv[8,9] \(64-bit\) " ) {
2022-11-11 12:53:43 -08:00
& " $scriptsDir /tls12-download-arm64.exe " github . com " /microsoft/vcpkg-tool/releases/download/ $versionDate /vcpkg-arm64.exe " " $vcpkgRootDir \vcpkg.exe "
2021-10-29 22:39:14 -07:00
} else {
& " $scriptsDir /tls12-download.exe " github . com " /microsoft/vcpkg-tool/releases/download/ $versionDate /vcpkg.exe " " $vcpkgRootDir \vcpkg.exe "
}
2021-02-04 10:15:44 -08:00
Write-Host " "
2016-09-18 20:50:08 -07:00
2021-02-04 10:15:44 -08:00
if ( $LASTEXITCODE -ne 0 )
2017-08-25 23:25:41 -07:00
{
2021-02-04 10:15:44 -08:00
Write-Error " Downloading vcpkg.exe failed. Please check your internet connection, or consider downloading a recent vcpkg.exe from https://github.com/microsoft/vcpkg-tool with a browser. "
2020-07-01 10:53:10 -07:00
throw
2016-09-18 20:50:08 -07:00
}
2020-07-01 10:53:10 -07:00
2023-08-24 16:20:42 -07:00
& " $vcpkgRootDir \vcpkg.exe " version - -disable -metrics
2023-07-25 20:35:26 -07:00
2021-01-13 14:06:06 -08:00
if ( $disableMetrics )
{
Set-Content -Value " " -Path " $vcpkgRootDir \vcpkg.disable-metrics " -Force
}
elseif ( -Not ( Test-Path " $vcpkgRootDir \vcpkg.disable-metrics " ) )
2020-02-13 18:12:12 -08:00
{
2021-01-13 14:06:06 -08:00
# Note that we intentionally leave any existing vcpkg.disable-metrics; once a user has
# opted out they should stay opted out.
2020-02-13 18:12:12 -08:00
Write-Host @"
2019-11-14 13:12:36 -08:00
Telemetry
- - - - - - - - -
2020-05-29 14:09:03 -07:00
vcpkg collects usage data in order to help us improve your experience .
The data collected by Microsoft is anonymous .
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics ,
passing - -disable -metrics to vcpkg on the command line ,
or by setting the VCPKG_DISABLE_METRICS environment variable .
2019-11-14 13:12:36 -08:00
2020-05-29 14:09:03 -07:00
Read more about vcpkg telemetry at docs / about / privacy . md
2019-11-14 13:12:36 -08:00
" @
2020-02-13 18:12:12 -08:00
}