+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
+}
+