From 1a672e37d6773fa8324d358d0191f4e6fce19d47 Mon Sep 17 00:00:00 2001 From: 5an7y Date: Thu, 2 Apr 2026 15:36:34 -0700 Subject: refactor: consolidate VS detection into Resolve-BuildEnvironment - Remove Initialize-DevShell as a separate step; VS Dev Shell setup is now fully owned by Resolve-BuildEnvironment alongside mode detection. This eliminates the ordering problem where vswhere ran unconditionally before knowing whether the environment was EWDK (which needs no VS). - Fix EWDK regression: EWDK mode now returns early before any vswhere or Dev Shell logic is invoked. - Fix Auto+WDK from plain terminal: the old isWdk guard required UCRTVersion to be set before the Dev Shell was opened, making Auto detection fail on a clean terminal. Removed the guard; the code now falls through to Dev Shell setup and validates UCRTVersion afterward. - Fix VSINSTALLDIR trailing-backslash mismatch: when the Dev Shell is already active, VSINSTALLDIR ends with '\' while vswhere installationPath does not. Added TrimEnd('\') on both sides before comparing. - Renumber Build-Samples.ps1 step comments (old Step 5 'Detect Build Environment' merged into Step 1; remaining steps renumbered). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Build-Samples.ps1 | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'Build-Samples.ps1') diff --git a/Build-Samples.ps1 b/Build-Samples.ps1 index a479177b..a73a2afa 100644 --- a/Build-Samples.ps1 +++ b/Build-Samples.ps1 @@ -292,9 +292,9 @@ function Build-SingleSample { # Step 1 - Prepare Build Environment # ============================================================================= -$root = (Get-Location).Path - -$selectedVsInstall = Initialize-DevShell -ReturnToDirectory $root +$root = (Get-Location).Path +$buildEnv = Resolve-BuildEnvironment -RepoRoot $root -RunMode $RunMode +$buildNumber = $buildEnv.BuildNumber Assert-MsBuildAvailable # ============================================================================= @@ -377,14 +377,7 @@ if ($sampleSet.Count -eq 0) { } # ============================================================================= -# Step 5 - Detect Build Environment -# ============================================================================= - -$buildEnv = Resolve-BuildEnvironment -RepoRoot $root -RunMode $RunMode -VsInstallation $selectedVsInstall -$buildNumber = $buildEnv.BuildNumber - -# ============================================================================= -# Step 6 - Determine InfVerif Options +# Step 5 - Determine InfVerif Options # ============================================================================= # # Samples must build cleanly, but certain InfVerif warnings are acceptable because @@ -400,13 +393,13 @@ else { } # ============================================================================= -# Step 7 - Load Exclusions +# Step 6 - Load Exclusions # ============================================================================= $exclusions = Import-SampleExclusions -CsvPath (Join-Path $root 'exclusions.csv') -BuildNumber $buildNumber # ============================================================================= -# Step 8 - Print Build Plan +# Step 7 - Print Build Plan # ============================================================================= $combinationsTotal = $sampleSet.Count * $Configurations.Count * $Platforms.Count @@ -439,7 +432,7 @@ Write-Output "" Write-Output "Building all combinations..." # ============================================================================= -# Step 9 - Execute Parallel Builds +# Step 8 - Execute Parallel Builds # ============================================================================= # Shared mutable state protected by a Mutex. This is required because @@ -587,7 +580,7 @@ $stopwatch.Stop() Write-Host "" # ============================================================================= -# Step 10 - Report Failures +# Step 9 - Report Failures # ============================================================================= Write-Output "" @@ -626,7 +619,7 @@ if ($buildState.SporadicSet.Count -gt 0) { } # ============================================================================= -# Step 11 - Final Summary +# Step 10 - Final Summary # ============================================================================= $elapsed = $stopwatch.Elapsed @@ -652,7 +645,7 @@ Write-Output " HTML report: $reportHtmlPath" Write-Output "--------------------------------------------------------------------" # ============================================================================= -# Step 12 - Generate Reports +# Step 11 - Generate Reports # ============================================================================= $sortedResults = $buildState.Results | Sort-Object { $_.Sample } -- cgit v1.3.1