Consolidate build scripts into a single Build-Samples.ps1#1363
Merged
5an7y-Microsoft merged 11 commits intodevelopfrom Mar 31, 2026
Merged
Consolidate build scripts into a single Build-Samples.ps1#13635an7y-Microsoft merged 11 commits intodevelopfrom
5an7y-Microsoft merged 11 commits intodevelopfrom
Conversation
- ListAllSamples.ps1: Enumerates .sln files and writes Samples.txt - Build-Samples.ps1: Unified build script reading Samples.txt with exclusion support, parallel execution, and report generation - Build-Sample.ps1: Fix retry bug where all-fail exits 0 instead of 1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Build-Samples.ps1: - Extract helper functions for readability (Resolve-BuildEnvironment, Import-SampleExclusions, Initialize-DevShell, Assert-MsBuildAvailable, Get-DiskFreeGB) - Add #Requires -Version 7.0 - Fix build_number to explicit [int] cast (was string from regex) - Fix multi-socket CPU handling (sum LogicalProcessors) - Fix NuGet path detection to use absolute repo root path - Support wildcard patterns in exclusion paths (-like vs ContainsKey) - Guard Invoke-Item for CI/automation (skip in non-interactive sessions) - Validate sample directories exist before building - Wrap Get-Volume in try/catch for UNC/network drives - Use Write-Host with carriage return for progress (Write-Progress unreliable in -Parallel runspaces) - Clean up variable names and add section comments - Use switch instead of if/elseif for exit codes ListAllSamples.ps1: - Fix NuGet packages filter regex to catch packages anywhere in path (was only matching paths starting with packages) Samples.txt: - Regenerated with fixed filter, remove BOM Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ListAllSamples.ps1: output sorted sample names to stdout instead of writing Samples.txt. The file output is replaced with Write-Output so callers can capture results via pipeline or command substitution. - Build-Samples.ps1: remove SampleListPath parameter. Default discovery now calls ListAllSamples.ps1 at runtime and consumes its stdout. Explicit -Samples array still works and is sorted alphabetically. Both paths guarantee a consistent alphabetical sample ordering. - Samples.txt: deleted. No longer needed as a pre-generated artifact. WDS_TestPass.cs is unaffected - it only passes -LogFilesDirectory and -InfOptions, neither of which changed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-Samples.ps1 - Delete Build-AllSamples.ps1 and Build-SampleSet.ps1 (replaced by Build-Samples.ps1) - Update ci.yml workflow to call Build-Samples.ps1 - Update Build-ChangedSamples.ps1 to call Build-Samples.ps1 - Rewrite Building-Locally.md Step 6 with new script usage and output format - Update Step 7 NuGet notes to reference Build-Samples.ps1
- Inline Build-Sample.ps1 logic as Build-SingleSample function in Build-Samples.ps1 - Pass function definition into parallel runspaces via $using: pattern - Replace exit codes with return values for in-process execution - Delete Build-Sample.ps1 (no longer needed as a separate script) - Update Build-ChangedSamples.ps1 trigger file list
- When -Samples contains wildcards (* or ?), discover all samples first then filter with -like (same pattern style as exclusions.csv) - Exact sample names still work as before without discovery overhead - Update parameter docs, examples, and Building-Locally.md
…w-build-samples # Conflicts: # Build-AllSamples.ps1 # Build-SampleSet.ps1
JakobL-MSFT
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the three separate build scripts (
Build-AllSamples.ps1,Build-SampleSet.ps1,Build-Sample.ps1) with a single unifiedBuild-Samples.ps1that handles all build scenarios. Adds a newListAllSamples.ps1for sample discovery.Motivation
The previous build system required users to choose between three scripts depending on the scenario, with a confusing call chain (
Build-AllSamples→Build-SampleSet→Build-Sample). This consolidation provides a single entry point while keeping the code maintainable through internal helper functions.Changes
New scripts
Build-Samples.ps1— Single build orchestrator that replaces all three scripts. Includes:Build-SingleSampleinternal function (formerlyBuild-Sample.ps1)Resolve-BuildEnvironment,Import-SampleExclusions, and other well-structured helpers-Samplesparameter (e.g..\Build-Samples -Samples 'tools.*')#Requiresdirective)ListAllSamples.ps1— Dedicated sample discovery script, decoupled from buildingDeleted scripts
Build-AllSamples.ps1Build-SampleSet.ps1Build-Sample.ps1Updated files
.github/workflows/ci.yml— CallsBuild-Samples.ps1instead ofBuild-AllSamples.ps1.github/scripts/Build-ChangedSamples.ps1— UsesBuild-Samples.ps1for both full and partial buildsBuilding-Locally.md— Rewritten Step 6 with new script usage, examples (including wildcards), and updated example outputUsage examples
Testing
CI workflow runs successfully on fork (5an7y-Microsoft/Windows-driver-samples-2)