]> vilimpoc.org git repositories - dotfiles/blobdiff - setup-windows-no-uac.ps1
dotfiles: drop the non-elevated ETW tracing, it never worked
[dotfiles] / setup-windows-no-uac.ps1
index f6500b8973361bfba96915fed5c2185ccf44ff90..11973000cdcdddc1a2663165d6f514c9e7e54058 100644 (file)
 
   What this installs / configures:
     - WinMerge on the user PATH
 
   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
     - BinSkim (binary hardening analyzer) in %LOCALAPPDATA%\Programs\BinSkim,
       on the user PATH
     - Global git identity, and core.sshCommand pointed at a Win32-OpenSSH
@@ -31,7 +35,7 @@ param(
     # 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
     # 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 = @()
 )
 
     [string[]] $Skip = @()
 )
 
@@ -90,6 +94,22 @@ function Add-WinMergeToUserPath {
     Add-ToUserPath $dir
 }
 
     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,
 function Install-BinSkim {
     # BinSkim checks the exact mitigations the native project enables in
     # CMakeLists.txt (CFG/XFG, CET, ASLR/HighEntropyVA, DEP, /GS, stack cookies,
@@ -288,6 +308,7 @@ if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::
 
 $steps = [ordered]@{
     WinMerge  = { Add-WinMergeToUserPath }
 
 $steps = [ordered]@{
     WinMerge  = { Add-WinMergeToUserPath }
+    VsWhere   = { Add-VsWhereToUserPath }
     BinSkim   = { Install-BinSkim }
     GitConfig = { Set-GlobalGitConfig }
 }
     BinSkim   = { Install-BinSkim }
     GitConfig = { Set-GlobalGitConfig }
 }