What this installs / configures:
- WinMerge on the user PATH
+ - vswhere.exe on the user PATH: the Visual Studio installer puts it in
+ %ProgramFiles(x86)%\Microsoft Visual Studio\Installer, which nothing adds
+ to the PATH, so build scripts (and VsDevCmd.bat itself) complain that
+ 'vswhere.exe' is not recognized
- BinSkim (binary hardening analyzer) in %LOCALAPPDATA%\Programs\BinSkim,
on the user PATH
- Global git identity, and core.sshCommand pointed at a Win32-OpenSSH
# for several, dot-call the script or use -Command:
# .\setup-windows-no-uac.ps1 -Skip BinSkim,GitConfig
# powershell -File .\setup-windows-no-uac.ps1 -Skip BinSkim
- [ValidateSet('WinMerge', 'BinSkim', 'GitConfig')]
+ [ValidateSet('WinMerge', 'VsWhere', 'BinSkim', 'GitConfig')]
[string[]] $Skip = @()
)
Add-ToUserPath $dir
}
+function Add-VsWhereToUserPath {
+ # vswhere.exe is how scripts locate Visual Studio (MSBuild, VsDevCmd.bat,
+ # the Windows SDK), and the VS installer drops it in a fixed directory that
+ # is never on the PATH. VsDevCmd.bat itself prints "'vswhere.exe' is not
+ # recognized" on every run without it. The directory is fixed by contract
+ # (32-bit Program Files, no version in the path), so there is nothing to
+ # search for: if it is missing, Visual Studio is not installed.
+ Write-Step 'vswhere on the user PATH'
+ $dir = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer'
+ if (-not (Test-Path (Join-Path $dir 'vswhere.exe'))) {
+ Write-Warning "vswhere.exe not found in $dir (no Visual Studio installer present); user PATH unchanged."
+ return
+ }
+ Add-ToUserPath $dir
+}
+
function Install-BinSkim {
# BinSkim checks the exact mitigations the native project enables in
# CMakeLists.txt (CFG/XFG, CET, ASLR/HighEntropyVA, DEP, /GS, stack cookies,
$steps = [ordered]@{
WinMerge = { Add-WinMergeToUserPath }
+ VsWhere = { Add-VsWhereToUserPath }
BinSkim = { Install-BinSkim }
GitConfig = { Set-GlobalGitConfig }
}