diff options
| author | 5an7y-Microsoft <[email protected]> | 2026-03-31 10:25:22 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-31 10:25:22 -0700 |
| commit | 3b06a5477ba38d830c35bf16045c7bb42039a8a2 (patch) | |
| tree | 3ca55eb1b13313cb8f488cab22e454e6945900e8 /ListAllSamples.ps1 | |
| parent | 05b65dac08c551a94e1d7fc282e35c546e00472e (diff) | |
| parent | 3a2a44ac95e464972b5244c33ec34c53eabe34b8 (diff) | |
Merge pull request #1363 from microsoft/user/jvalesmena/new-build-samples
Consolidate build scripts into a single Build-Samples.ps1
Diffstat (limited to 'ListAllSamples.ps1')
| -rw-r--r-- | ListAllSamples.ps1 | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ListAllSamples.ps1 b/ListAllSamples.ps1 new file mode 100644 index 00000000..1a1a4a78 --- /dev/null +++ b/ListAllSamples.ps1 @@ -0,0 +1,49 @@ +<# +.SYNOPSIS + Enumerates all available sample solutions in the repository and writes them to the console. + +.DESCRIPTION + Searches for all .sln files recursively from the repo root, excludes NuGet package directories + (paths containing 'packages' as a segment), computes a normalized sample name for each, and writes + the sorted list to stdout (one sample name per line). + + The sample name is derived from the relative directory path: backslashes are replaced with dots + and the result is lowercased. + +.EXAMPLE + .\ListAllSamples + + Discovers all samples and writes the sorted names to the console. + +.OUTPUTS + Sorted sample names written to stdout, one per line. +#> + +[CmdletBinding()] +param() + +$root = (Get-Location).Path + +# Discover all .sln files +$solutionFiles = Get-ChildItem -Path $root -Recurse -Filter *.sln | Select-Object -ExpandProperty FullName + +$sampleNames = @{} + +foreach ($file in $solutionFiles) { + $dir = (Get-Item $file).DirectoryName + $dirNorm = $dir.Replace($root, '').Trim('\').Replace('\', '.').ToLower() + + if ($dirNorm -match '(^|\.|\b)packages(\.|$)') { + Write-Verbose "Ignored NuGet package directory: $dirNorm" + continue + } + + if (-not $sampleNames.ContainsKey($dirNorm)) { + $sampleNames[$dirNorm] = $true + } +} + +$sortedNames = $sampleNames.Keys | Sort-Object + +Write-Verbose "Found $($sortedNames.Count) samples." +$sortedNames | Write-Output |
