Skip to content

Commit a08d8e9

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 a08d8e9

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

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: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
$credProviderFound = $false
95+
if ($env:NUGET_PLUGIN_PATHS)
96+
{
97+
# If NUGET_PLUGIN_PATHS is set, NuGet will look there instead of the default location.
98+
$credProviderFound = Test-Path $env:NUGET_PLUGIN_PATHS
99+
}
100+
else
101+
{
102+
$credProviderFound = (Test-Path "${env:USERPROFILE}\.nuget\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe") -or
103+
(Test-Path "${env:USERPROFILE}\.nuget\plugins\netcore\CredentialProvider.Microsoft\CredentialProvider.Microsoft.dll")
104+
}
105+
Check "Azure Artifacts Credential Provider" $credProviderFound "iex ""& { `$(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"""
106+
107+
# --- Developer Mode / Symlinks ---
108+
Write-Host ""
109+
Write-Host "System Configuration:" -ForegroundColor White
110+
111+
$devMode = $false
112+
try
113+
{
114+
$devModeReg = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -ErrorAction SilentlyContinue
115+
$devMode = $devModeReg -and $devModeReg.AllowDevelopmentWithoutDevLicense -eq 1
116+
}
117+
catch {}
118+
119+
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
120+
Check "Developer Mode or Admin$(if ($devMode) { ' (Developer Mode)' } elseif ($isAdmin) { ' (Administrator)' })" ($devMode -or $isAdmin) "Settings -> System -> For developers -> Developer Mode"
121+
122+
# --- Optional tools ---
123+
Write-Host ""
124+
Write-Host "Optional Tools:" -ForegroundColor White
125+
126+
$windbg = Get-Command "WinDbgX.exe" -ErrorAction SilentlyContinue
127+
Check "WinDbg (for /attachdebugger)" ($null -ne $windbg) "winget install Microsoft.WinDbg" -Optional
128+
129+
$python = Get-Command "python3" -ErrorAction SilentlyContinue
130+
if (-not $python) { $python = Get-Command "python" -ErrorAction SilentlyContinue }
131+
Check "Python 3 (for validation scripts)" ($null -ne $python) "winget install Python.Python.3.13" -Optional
132+
133+
# --- Summary ---
134+
Write-Host ""
135+
if ($script:Errors -eq 0)
136+
{
137+
Write-Host "All prerequisites found. Ready to build!" -ForegroundColor Green
138+
Write-Host ""
139+
Write-Host " cmake ."
140+
Write-Host " cmake --build . -- -m"
141+
Write-Host ""
142+
}
143+
else
144+
{
145+
Write-Host "$($script:Errors) prerequisite(s) missing. Install them and re-run this script." -ForegroundColor Red
146+
Write-Host ""
147+
exit 1
148+
}

0 commit comments

Comments
 (0)