Add dev environment setup with WinGet Configuration (#40117)

* Add setup-dev-env.ps1 and WinGet configuration for dev prerequisites Add a one-command developer environment setup that uses WinGet Configuration (DSC) to install all build prerequisites: Developer Mode, CMake, Visual Studio 2022, and the required VS workloads/components. New files: - tools/setup-dev-env.ps1: Detects any existing VS 2022 edition (Community/Professional/Enterprise) and runs the matching WinGet configuration. Defaults to Community when no VS 2022 is found. - .vsconfig: Declares the required VS components (MSVC, ATL, Clang, Windows SDK 26100, UWP tools, .NET desktop/WinUI workloads) so VS Installer can import them directly. - .config/configuration.winget: WinGet DSC config for VS Community. - .config/configuration.vsProfessional.winget: Same for Professional. - .config/configuration.vsEnterprise.winget: Same for Enterprise. Updated doc/docs/dev-loop.md to document the automated setup and reference the new .vsconfig and winget configuration files, while keeping manual install instructions in a collapsed details block. * doc: add winget configure --enable to manual setup instructions Address review feedback: document that 'winget configure --enable' is required before running winget configure manually, since the feature may not be enabled by default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Ben Hillis committed May 8, 2026 at 09:14 UTC caf7e59becb90efa03fe74116bb2084224f30928
6 files changed +270 -13
.config/configuration.vsEnterprise.winget new
+45
@@ -0,0 +1,45 @@
1 +# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
2 +# Reference: https://github.com/microsoft/WSL/blob/master/doc/docs/dev-loop.md
3 +#
4 +# Usage: winget configure -f .config/configuration.vsEnterprise.winget
5 +#
6 +# Visual Studio 2022 Enterprise edition. For other editions use:
7 +# .config/configuration.winget (Community, default)
8 +# .config/configuration.vsProfessional.winget (Professional)
9 +properties:
10 + resources:
11 + - resource: Microsoft.Windows.Settings/WindowsSettings
12 + directives:
13 + description: Enable Developer Mode (required for symbolic link support)
14 + allowPrerelease: true
15 + securityContext: elevated
16 + settings:
17 + DeveloperMode: true
18 + - resource: Microsoft.WinGet.DSC/WinGetPackage
19 + id: cmake
20 + directives:
21 + description: Install CMake
22 + securityContext: elevated
23 + settings:
24 + id: Kitware.CMake
25 + source: winget
26 + - resource: Microsoft.WinGet.DSC/WinGetPackage
27 + id: vsPackage
28 + directives:
29 + description: Install Visual Studio 2022 Enterprise
30 + securityContext: elevated
31 + settings:
32 + id: Microsoft.VisualStudio.2022.Enterprise
33 + source: winget
34 + - resource: Microsoft.VisualStudio.DSC/VSComponents
35 + dependsOn:
36 + - vsPackage
37 + directives:
38 + description: Install required VS workloads from .vsconfig
39 + allowPrerelease: true
40 + securityContext: elevated
41 + settings:
42 + productId: Microsoft.VisualStudio.Product.Enterprise
43 + channelId: VisualStudio.17.Release
44 + vsConfigFile: '${WinGetConfigRoot}\..\.vsconfig'
45 + configurationVersion: 0.2.0
.config/configuration.vsProfessional.winget new
+45
@@ -0,0 +1,45 @@
1 +# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
2 +# Reference: https://github.com/microsoft/WSL/blob/master/doc/docs/dev-loop.md
3 +#
4 +# Usage: winget configure -f .config/configuration.vsProfessional.winget
5 +#
6 +# Visual Studio 2022 Professional edition. For other editions use:
7 +# .config/configuration.winget (Community, default)
8 +# .config/configuration.vsEnterprise.winget (Enterprise)
9 +properties:
10 + resources:
11 + - resource: Microsoft.Windows.Settings/WindowsSettings
12 + directives:
13 + description: Enable Developer Mode (required for symbolic link support)
14 + allowPrerelease: true
15 + securityContext: elevated
16 + settings:
17 + DeveloperMode: true
18 + - resource: Microsoft.WinGet.DSC/WinGetPackage
19 + id: cmake
20 + directives:
21 + description: Install CMake
22 + securityContext: elevated
23 + settings:
24 + id: Kitware.CMake
25 + source: winget
26 + - resource: Microsoft.WinGet.DSC/WinGetPackage
27 + id: vsPackage
28 + directives:
29 + description: Install Visual Studio 2022 Professional
30 + securityContext: elevated
31 + settings:
32 + id: Microsoft.VisualStudio.2022.Professional
33 + source: winget
34 + - resource: Microsoft.VisualStudio.DSC/VSComponents
35 + dependsOn:
36 + - vsPackage
37 + directives:
38 + description: Install required VS workloads from .vsconfig
39 + allowPrerelease: true
40 + securityContext: elevated
41 + settings:
42 + productId: Microsoft.VisualStudio.Product.Professional
43 + channelId: VisualStudio.17.Release
44 + vsConfigFile: '${WinGetConfigRoot}\..\.vsconfig'
45 + configurationVersion: 0.2.0
.config/configuration.winget new
+45
@@ -0,0 +1,45 @@
1 +# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
2 +# Reference: https://github.com/microsoft/WSL/blob/master/doc/docs/dev-loop.md
3 +#
4 +# Usage: winget configure -f .config/configuration.winget
5 +#
6 +# This is the default configuration (VS Community). For other editions use:
7 +# .config/configuration.vsProfessional.winget
8 +# .config/configuration.vsEnterprise.winget
9 +properties:
10 + resources:
11 + - resource: Microsoft.Windows.Settings/WindowsSettings
12 + directives:
13 + description: Enable Developer Mode (required for symbolic link support)
14 + allowPrerelease: true
15 + securityContext: elevated
16 + settings:
17 + DeveloperMode: true
18 + - resource: Microsoft.WinGet.DSC/WinGetPackage
19 + id: cmake
20 + directives:
21 + description: Install CMake
22 + securityContext: elevated
23 + settings:
24 + id: Kitware.CMake
25 + source: winget
26 + - resource: Microsoft.WinGet.DSC/WinGetPackage
27 + id: vsPackage
28 + directives:
29 + description: Install Visual Studio 2022 Community
30 + securityContext: elevated
31 + settings:
32 + id: Microsoft.VisualStudio.2022.Community
33 + source: winget
34 + - resource: Microsoft.VisualStudio.DSC/VSComponents
35 + dependsOn:
36 + - vsPackage
37 + directives:
38 + description: Install required VS workloads from .vsconfig
39 + allowPrerelease: true
40 + securityContext: elevated
41 + settings:
42 + productId: Microsoft.VisualStudio.Product.Community
43 + channelId: VisualStudio.17.Release
44 + vsConfigFile: '${WinGetConfigRoot}\..\.vsconfig'
45 + configurationVersion: 0.2.0
.vsconfig new
+21
@@ -0,0 +1,21 @@
1 +{
2 + "version": "1.0",
3 + "components": [
4 + "Microsoft.Component.MSBuild",
5 + "Microsoft.VisualStudio.Component.VC.CoreIde",
6 + "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
7 + "Microsoft.VisualStudio.Component.VC.Tools.ARM64",
8 + "Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre",
9 + "Microsoft.VisualStudio.Component.VC.Tools.ARM64.Spectre",
10 + "Microsoft.VisualStudio.Component.VC.ATL",
11 + "Microsoft.VisualStudio.Component.VC.ATL.ARM64",
12 + "Microsoft.VisualStudio.Component.VC.ATL.Spectre",
13 + "Microsoft.VisualStudio.Component.VC.ATL.ARM64.Spectre",
14 + "Microsoft.VisualStudio.Component.VC.Llvm.Clang",
15 + "Microsoft.VisualStudio.Component.Windows11SDK.26100",
16 + "Microsoft.VisualStudio.Component.UWP.VC.ARM64",
17 + "Microsoft.VisualStudio.Workload.ManagedDesktop",
18 + "Microsoft.VisualStudio.Workload.Universal",
19 + "Microsoft.VisualStudio.Workload.NativeDesktop"
20 + ]
21 +}
doc/docs/dev-loop.md
+29 -13
@@ -2,22 +2,38 @@
2
3 ## Prerequisites
4
5 -The following tools are required to build WSL:
5 +All prerequisites can be installed automatically by running:
6 +
7 +```
8 +tools\setup-dev-env.ps1
9 +```
10 +
11 +This uses [WinGet Configuration](https://learn.microsoft.com/windows/package-manager/configuration/) to install Developer Mode, CMake, Visual Studio 2022, and the required workloads from [`.vsconfig`](https://github.com/microsoft/WSL/blob/master/.vsconfig). If VS 2022 is already installed, the script detects your edition (Community, Professional, or Enterprise) and uses the matching configuration. If no VS 2022 is found, it defaults to Community.
12 +
13 +You can also run a WinGet configuration directly for your edition:
14 +
15 +```
16 +winget configure --enable
17 +winget configure -f .config/configuration.winget # Community (default)
18 +winget configure -f .config/configuration.vsProfessional.winget # Professional
19 +winget configure -f .config/configuration.vsEnterprise.winget # Enterprise
20 +```
21 +
22 +> **Note:** `winget configure --enable` is required to enable the configuration feature. The `setup-dev-env.ps1` script runs this automatically.
23 +
24 +<details>
25 +<summary>Manual installation</summary>
26 +
27 +If you prefer to install prerequisites manually:
28
29 - CMake >= 3.25
30 - Can be installed with `winget install Kitware.CMake`
9 -- Visual Studio with the following components:
10 - - Windows SDK 26100
11 - - MSBuild
12 - - Universal Windows platform support for v143 build tools (X64 and ARM64)
13 - - MSVC v143 - VS 2022 C++ ARM64 build tools (Latest + Spectre) (X64 and ARM64)
14 - - C++ core features
15 - - C++ ATL for latest v143 tools (X64 and ARM64)
16 - - C++ Clang compiler for Windows
17 - - .NET desktop development
18 - - .NET WinUI app development tools
19 -
20 -- Building WSL requires support for symbolic links. To ensure this capability, enable [Developer Mode](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) in Windows Settings or execute the build process with Administrator privileges.
31 +- Visual Studio 2022 with the required components:
32 + - Use VS Installer → More → Import configuration and select [`.vsconfig`](https://github.com/microsoft/WSL/blob/master/.vsconfig)
33 + - Or: `winget install Microsoft.VisualStudio.2022.Community --override "--wait --quiet --config .vsconfig"`
34 +- Enable [Developer Mode](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) in Windows Settings, or run builds with Administrator privileges (required for symbolic link support)
35 +
36 +</details>
37
38 ### ARM64 development
39
tools/setup-dev-env.ps1 new
+85
@@ -0,0 +1,85 @@
1 +<#
2 +.SYNOPSIS
3 + Sets up the development environment for building WSL.
4 +.DESCRIPTION
5 + Detects any existing Visual Studio 2022 installation and runs the
6 + matching WinGet Configuration to install all prerequisites:
7 + Developer Mode, CMake, Visual Studio 2022, and required workloads
8 + from .vsconfig.
9 +
10 + If VS 2022 is already installed, the script picks the configuration
11 + matching that edition (Community, Professional, or Enterprise).
12 + If no VS 2022 is found, it defaults to Community edition.
13 +.EXAMPLE
14 + .\tools\setup-dev-env.ps1
15 +#>
16 +
17 +Set-StrictMode -Version Latest
18 +$ErrorActionPreference = "Stop"
19 +
20 +$repoRoot = (Resolve-Path "$PSScriptRoot\..").Path
21 +$configDir = Join-Path $repoRoot ".config"
22 +
23 +# ── Detect existing VS 2022 edition ─────────────────────────────────
24 +$configFile = "configuration.winget" # default: Community
25 +$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
26 +
27 +if (Test-Path $vswhere)
28 +{
29 + $productId = (& $vswhere -version "[17.0,18.0)" -products * -latest -property productId 2>$null |
30 + Select-Object -First 1)
31 +
32 + if ($productId) { $productId = $productId.Trim() }
33 +
34 + switch ($productId)
35 + {
36 + "Microsoft.VisualStudio.Product.Professional" {
37 + $configFile = "configuration.vsProfessional.winget"
38 + Write-Host "Detected VS 2022 Professional - using $configFile" -ForegroundColor Green
39 + }
40 + "Microsoft.VisualStudio.Product.Enterprise" {
41 + $configFile = "configuration.vsEnterprise.winget"
42 + Write-Host "Detected VS 2022 Enterprise - using $configFile" -ForegroundColor Green
43 + }
44 + "Microsoft.VisualStudio.Product.Community" {
45 + Write-Host "Detected VS 2022 Community - using $configFile" -ForegroundColor Green
46 + }
47 + default {
48 + Write-Host "No VS 2022 found - will install Community edition" -ForegroundColor Yellow
49 + }
50 + }
51 +}
52 +else
53 +{
54 + Write-Host "No VS 2022 found - will install Community edition" -ForegroundColor Yellow
55 +}
56 +
57 +$configPath = Join-Path $configDir $configFile
58 +
59 +# ── Run WinGet Configuration ────────────────────────────────────────
60 +Write-Host ""
61 +Write-Host "Running WinGet Configuration ($configFile)..." -ForegroundColor Cyan
62 +Write-Host " This will install: Developer Mode, CMake, VS 2022 + required components"
63 +Write-Host ""
64 +
65 +winget configure --enable
66 +if ($LASTEXITCODE -ne 0)
67 +{
68 + Write-Host "Failed to enable WinGet configuration feature." -ForegroundColor Red
69 + exit 1
70 +}
71 +
72 +winget configure -f "$configPath" --accept-configuration-agreements
73 +if ($LASTEXITCODE -ne 0)
74 +{
75 + Write-Host "Failed to apply WinGet configuration file: $configFile" -ForegroundColor Red
76 + exit 1
77 +}
78 +
79 +# ── Done ────────────────────────────────────────────────────────────
80 +Write-Host ""
81 +Write-Host "All prerequisites installed. Ready to build!" -ForegroundColor Green
82 +Write-Host ""
83 +Write-Host " cmake ."
84 +Write-Host " cmake --build . -- -m"
85 +Write-Host ""