]> vilimpoc.org git repositories - dotfiles/blame_incremental - setup-windows.bat
dotfiles: put vswhere.exe on the user PATH
[dotfiles] / setup-windows.bat
... / ...
CommitLineData
1@echo off\r
2\r
3@rem ---------------------------------------------------------------------------\r
4@rem setup-windows.bat - provision a fresh Windows box for native development\r
5@rem ---------------------------------------------------------------------------\r
6\r
7@rem --- Non-admin (per-user) winget installs ---\r
8winget install Anthropic.ClaudeCode\r
9winget install Git.Git\r
10winget install Microsoft.DotNet.SDK.10\r
11winget install Microsoft.PowerShell Microsoft.Sysinternals.ProcessExplorer Microsoft.Sysinternals.ProcessMonitor Microsoft.Sysinternals.SDelete Microsoft.VisualStudioCode Microsoft.WindowsTerminal\r
12winget install Oracle.VirtualBox\r
13winget install Python.Python.3.13\r
14winget install WinMerge.WinMerge\r
15\r
16@rem OpenCppCoverage: native (PE) line coverage for the C++ binaries. run-coverage-occ.py drives the\r
17@rem pytest suite under it to produce an HTML report (the binaries under test build with PDBs,\r
18@rem which it reads). The installer elevates via UAC.\r
19winget install OpenCppCoverage.OpenCppCoverage\r
20\r
21@rem --- WiX 5.0.2, pinned on purpose ---\r
22@rem WiX packages our proprietary software into MSIs, and the version is pinned to keep that\r
23@rem free of a fee. 5.0.2 is the last release distributed under the Microsoft Reciprocal\r
24@rem License alone. From 6.0 onward the package also carries OSMFEULA.txt, an Open Source\r
25@rem Maintenance Fee agreement: a monthly fee owed by anyone who uses the PREBUILT BINARIES\r
26@rem as part of revenue-generating activity and has annual gross revenue >= US$10,000.\r
27@rem\r
28@rem It is a fee for the binaries, not a restriction on what we ship - MS-RL is file-scoped\r
29@rem and never reached the MSIs WiX builds, under any version - but 5.0.2 owes nothing.\r
30@rem The 6.x/7.x SOURCE is still MS-RL too, so self-compiling is another way out; a pin is\r
31@rem the cheaper one. This replaces `winget install WiXToolset.WiXCLI`, which has no version\r
32@rem selector and so installs the latest (7.0.0 today, EULA and all).\r
33@rem\r
34@rem PIN THE MSBUILD SIDE TOO. A .wixproj referencing WixToolset.Sdk without a version\r
35@rem resolves to the latest - 7.x, same EULA - and nothing here constrains it. Pin it in the\r
36@rem project: <Project Sdk="WixToolset.Sdk/5.0.2">.\r
37@rem\r
38@rem dotnet.exe is called by full path: winget put the SDK on the machine PATH a few lines\r
39@rem ago, but this cmd session inherited its environment before that and cannot see it.\r
40@rem install-then-update is for re-runs - install fails once the tool is there, and update\r
41@rem then holds it at exactly 5.0.2 - which keeps this script idempotent like the rest.\r
42set "DOTNET_EXE=%ProgramFiles%\dotnet\dotnet.exe"\r
43"%DOTNET_EXE%" tool install --global wix --version 5.0.2 || "%DOTNET_EXE%" tool update --global wix --version 5.0.2\r
44\r
45@rem Report what the pin actually produced. By full path again, and because the shim lands in\r
46@rem a directory this session's PATH predates: expect "5.0.2+<commit>", not 7.x.\r
47"%USERPROFILE%\.dotnet\tools\wix.exe" --version\r
48\r
49@rem ---------------------------------------------------------------------------\r
50@rem No package manager needed for the Windows build\r
51@rem\r
52@rem Just:\r
53@rem cd windows && cmake -B build -G "Visual Studio 17 2022" -A x64 && cmake --build build --config Release\r
54@rem ---------------------------------------------------------------------------\r
55\r
56@rem --- Elevated installs (VS2022, WDK, system tools) ---\r
57@rem The elevated script runs in its own window and logs to setup-windows-uac.log.\r
58@rem -PassThru + $p.ExitCode propagates its real exit code back through to ERRORLEVEL.\r
59set "UAC_LOG=%~dp0setup-windows-uac.log"\r
60if exist "%UAC_LOG%" del "%UAC_LOG%"\r
61\r
62powershell -NoProfile -Command "$p = Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-File','""%~dp0setup-windows-with-uac.ps1""' -Wait -PassThru; exit $p.ExitCode"\r
63set "UAC_RC=%ERRORLEVEL%"\r
64\r
65@rem --- Surface the elevated session's output (its window has already closed) ---\r
66if exist "%UAC_LOG%" (\r
67 echo.\r
68 echo ===== elevated setup log ^(%UAC_LOG%^) =====\r
69 type "%UAC_LOG%"\r
70 echo ===== end of elevated setup log =====\r
71) else (\r
72 echo [setup-windows] WARNING: no elevated log found at "%UAC_LOG%".\r
73 echo [setup-windows] The elevated window may have been cancelled at the UAC prompt.\r
74)\r
75\r
76@rem --- Non-elevated PowerShell half ---\r
77@rem WinMerge on the user PATH, BinSkim, and the global git config (identity +\r
78@rem core.sshCommand -> a Win32-OpenSSH client, so git shares the Windows\r
79@rem ssh-agent). EDIT THE GIT IDENTITY at the top of setup-windows-no-uac.ps1\r
80@rem before the first run.\r
81@rem\r
82@rem Deliberately NOT elevated: every step writes per-user state (the HKCU PATH,\r
83@rem the .gitconfig under %USERPROFILE%), which the elevated half would write to\r
84@rem the administrator profile instead.\r
85@rem\r
86@rem AFTER the elevated half on purpose: core.sshCommand prefers the ssh.exe that\r
87@rem half unpacks beside rsync.exe - a push through the in-box client is capped\r
88@rem at ~17MB/s - and it can only prefer it once it is on disk. Run either way,\r
89@rem including when the elevated half failed above: nothing here depends on it,\r
90@rem and the fallback is the in-box client that Windows already has.\r
91@rem\r
92@rem Non-fatal: these are conveniences, and the elevated half is the part worth\r
93@rem the UAC prompt. A failure warns and provisioning continues.\r
94powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0setup-windows-no-uac.ps1"\r
95if not "%ERRORLEVEL%"=="0" echo [setup-windows] WARNING: setup-windows-no-uac.ps1 reported a failure ^(see above^); continuing.\r
96\r
97if not "%UAC_RC%"=="0" (\r
98 echo.\r
99 echo [setup-windows] ELEVATED SETUP FAILED ^(exit code %UAC_RC%^). See log above.\r
100 exit /b %UAC_RC%\r
101)\r
102echo.\r
103echo [setup-windows] Elevated setup completed successfully.\r
104\r
105@rem Removed: this doesn't work as well as I hoped, maybe try again later\r
106@rem -- Install Headroom ---\r
107@rem py -m pip install "headroom-ai[all]"\r
108@rem npm install headroom-ai\r
109\r
110py -m pip install Pillow