Skip to content

Commit f335c0b

Browse files
Ben HillisCopilot
andcommitted
Add setup-dev-env.ps1 to validate development prerequisites
Checks for CMake, Visual Studio components (Clang, ATL, MSBuild), Windows SDK 26100, Developer Mode, and optional tools (WinDbg, Python). Reports missing items with install instructions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fd2375a commit f335c0b

2 files changed

Lines changed: 144 additions & 0 deletions

File tree

doc/docs/dev-loop.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Prerequisites
44

5+
You can verify all prerequisites are installed by running `tools\setup-dev-env.ps1`.
6+
57
The following tools are required to build WSL:
68

79
- CMake >= 3.25

tools/setup-dev-env.ps1

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<#
2+
.SYNOPSIS
3+
Checks that all prerequisites for building WSL are installed.
4+
.DESCRIPTION
5+
Validates the development environment and reports missing tools
6+
with installation instructions. Run this before your first build.
7+
.EXAMPLE
8+
.\tools\setup-dev-env.ps1
9+
#>
10+
11+
Set-StrictMode -Version Latest
12+
$ErrorActionPreference = "Stop"
13+
14+
$script:Errors = 0
15+
16+
function Check($Name, $Result, $Fix, [switch]$Optional)
17+
{
18+
if ($Result)
19+
{
20+
Write-Host " [OK] $Name" -ForegroundColor Green
21+
}
22+
elseif ($Optional)
23+
{
24+
Write-Host " [OPTIONAL] $Name" -ForegroundColor DarkYellow
25+
Write-Host " -> $Fix" -ForegroundColor Yellow
26+
}
27+
else
28+
{
29+
Write-Host " [MISSING] $Name" -ForegroundColor Red
30+
Write-Host " -> $Fix" -ForegroundColor Yellow
31+
$script:Errors++
32+
}
33+
}
34+
35+
Write-Host ""
36+
Write-Host "WSL Development Environment Check" -ForegroundColor Cyan
37+
Write-Host "==================================" -ForegroundColor Cyan
38+
Write-Host ""
39+
40+
# --- CMake ---
41+
Write-Host "Build Tools:" -ForegroundColor White
42+
$cmake = Get-Command "cmake" -ErrorAction SilentlyContinue
43+
$cmakeVersion = $null
44+
$cmakeOk = $false
45+
if ($cmake)
46+
{
47+
$cmakeVersion = [version]((cmake --version | Select-Object -First 1) -replace '[^0-9.]', '')
48+
$cmakeOk = $cmakeVersion -ge [version]"3.25"
49+
}
50+
Check "CMake >= 3.25$(if ($cmakeVersion) { " (found $cmakeVersion)" })" $cmakeOk "winget install Kitware.CMake"
51+
52+
# --- Visual Studio ---
53+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
54+
$vsInstall = $null
55+
if (Test-Path $vswhere)
56+
{
57+
$vsInstall = & $vswhere -latest -property installationPath 2>$null
58+
}
59+
Check "Visual Studio 2022+" ($null -ne $vsInstall) "Install Visual Studio 2022: https://visualstudio.microsoft.com/"
60+
61+
# --- VS Components (only check if VS is found) ---
62+
if ($vsInstall)
63+
{
64+
Write-Host ""
65+
Write-Host "Visual Studio Components:" -ForegroundColor White
66+
67+
$installedComponents = @(& $vswhere -latest -property catalog_productLineVersion 2>$null)
68+
$vsComponents = & $vswhere -latest -format json 2>$null | ConvertFrom-Json
69+
70+
# Check for specific required components via their markers
71+
$clangPath = Join-Path $vsInstall "VC\Tools\Llvm\x64\bin\clang-format.exe"
72+
Check "C++ Clang Compiler for Windows" (Test-Path $clangPath) "VS Installer -> Modify -> Individual Components -> C++ Clang Compiler for Windows"
73+
74+
$atlPath = Get-ChildItem -Path (Join-Path $vsInstall "VC\Tools\MSVC") -Filter "atlbase.h" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
75+
Check "C++ ATL for latest v143 tools" ($null -ne $atlPath) "VS Installer -> Modify -> Individual Components -> C++ ATL for latest v143 build tools"
76+
77+
$msbuild = Get-Command "msbuild" -ErrorAction SilentlyContinue
78+
if (-not $msbuild)
79+
{
80+
$msbuild = Get-ChildItem -Path $vsInstall -Filter "MSBuild.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
81+
}
82+
Check "MSBuild" ($null -ne $msbuild) "VS Installer -> Modify -> Individual Components -> MSBuild"
83+
}
84+
85+
# --- Windows SDK ---
86+
Write-Host ""
87+
Write-Host "Windows SDK:" -ForegroundColor White
88+
$sdkPath = "${env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.26100.0"
89+
Check "Windows SDK 26100" (Test-Path $sdkPath) "VS Installer -> Modify -> Individual Components -> Windows 11 SDK (10.0.26100.0)"
90+
91+
# --- NuGet Credential Provider (Azure DevOps feed) ---
92+
Write-Host ""
93+
Write-Host "NuGet:" -ForegroundColor White
94+
$credProviderPaths = @(
95+
"${env:USERPROFILE}\.nuget\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe",
96+
"${env:USERPROFILE}\.nuget\plugins\netcore\CredentialProvider.Microsoft\CredentialProvider.Microsoft.dll"
97+
)
98+
$credProviderFound = $credProviderPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
99+
Check "Azure Artifacts Credential Provider" ($null -ne $credProviderFound) "iex ""& { `$(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"""
100+
101+
# --- Developer Mode / Symlinks ---
102+
Write-Host ""
103+
Write-Host "System Configuration:" -ForegroundColor White
104+
105+
$devMode = $false
106+
try
107+
{
108+
$devModeReg = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -ErrorAction SilentlyContinue
109+
$devMode = $devModeReg -and $devModeReg.AllowDevelopmentWithoutDevLicense -eq 1
110+
}
111+
catch {}
112+
113+
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
114+
Check "Developer Mode or Admin$(if ($devMode) { ' (Developer Mode)' } elseif ($isAdmin) { ' (Administrator)' })" ($devMode -or $isAdmin) "Settings -> System -> For developers -> Developer Mode"
115+
116+
# --- Optional tools ---
117+
Write-Host ""
118+
Write-Host "Optional Tools:" -ForegroundColor White
119+
120+
$windbg = Get-Command "WinDbgX.exe" -ErrorAction SilentlyContinue
121+
Check "WinDbg (for /attachdebugger)" ($null -ne $windbg) "winget install Microsoft.WinDbg" -Optional
122+
123+
$python = Get-Command "python3" -ErrorAction SilentlyContinue
124+
if (-not $python) { $python = Get-Command "python" -ErrorAction SilentlyContinue }
125+
Check "Python 3 (for validation scripts)" ($null -ne $python) "winget install Python.Python.3.13" -Optional
126+
127+
# --- Summary ---
128+
Write-Host ""
129+
if ($script:Errors -eq 0)
130+
{
131+
Write-Host "All prerequisites found. Ready to build!" -ForegroundColor Green
132+
Write-Host ""
133+
Write-Host " cmake ."
134+
Write-Host " cmake --build . -- -m"
135+
Write-Host ""
136+
}
137+
else
138+
{
139+
Write-Host "$($script:Errors) prerequisite(s) missing. Install them and re-run this script." -ForegroundColor Red
140+
Write-Host ""
141+
exit 1
142+
}

0 commit comments

Comments
 (0)