95 lines
2.7 KiB
PowerShell
95 lines
2.7 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
<#
|
|
.SYNOPSIS
|
|
Builds (and optionally tests) all module solutions under src/.
|
|
|
|
.DESCRIPTION
|
|
Discovers all *.sln files under src/ (excluding the root StellaOps.sln)
|
|
and runs dotnet build on each. Pass -Test to also run dotnet test.
|
|
|
|
.PARAMETER Test
|
|
Also run dotnet test on each solution after building.
|
|
|
|
.PARAMETER Configuration
|
|
Build configuration. Defaults to Debug.
|
|
|
|
.EXAMPLE
|
|
.\scripts\build-all-solutions.ps1
|
|
.\scripts\build-all-solutions.ps1 -Test
|
|
.\scripts\build-all-solutions.ps1 -Test -Configuration Release
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[switch]$Test,
|
|
[ValidateSet('Debug', 'Release')]
|
|
[string]$Configuration = 'Debug'
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
|
$srcDir = Join-Path $repoRoot 'src'
|
|
|
|
$solutions = Get-ChildItem -Path $srcDir -Filter '*.sln' -Recurse |
|
|
Where-Object { $_.Name -ne 'StellaOps.sln' } |
|
|
Sort-Object FullName
|
|
|
|
if ($solutions.Count -eq 0) {
|
|
Write-Error 'No solution files found under src/.'
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Found $($solutions.Count) solution(s) to build." -ForegroundColor Cyan
|
|
Write-Host ''
|
|
|
|
$buildPass = @()
|
|
$buildFail = @()
|
|
$testPass = @()
|
|
$testFail = @()
|
|
$testSkipped = @()
|
|
|
|
foreach ($sln in $solutions) {
|
|
$rel = [System.IO.Path]::GetRelativePath($repoRoot, $sln.FullName)
|
|
Write-Host "--- BUILD: $rel ---" -ForegroundColor Yellow
|
|
|
|
dotnet build $sln.FullName --configuration $Configuration --nologo -v quiet
|
|
if ($LASTEXITCODE -eq 0) {
|
|
$buildPass += $rel
|
|
} else {
|
|
$buildFail += $rel
|
|
Write-Host " FAILED" -ForegroundColor Red
|
|
continue # skip test if build failed
|
|
}
|
|
|
|
if ($Test) {
|
|
Write-Host "--- TEST: $rel ---" -ForegroundColor Yellow
|
|
dotnet test $sln.FullName --configuration $Configuration --nologo --no-build -v quiet
|
|
if ($LASTEXITCODE -eq 0) {
|
|
$testPass += $rel
|
|
} else {
|
|
$testFail += $rel
|
|
Write-Host " TEST FAILED" -ForegroundColor Red
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host ''
|
|
Write-Host '========== Summary ==========' -ForegroundColor Cyan
|
|
Write-Host "Build passed : $($buildPass.Count)" -ForegroundColor Green
|
|
if ($buildFail.Count -gt 0) {
|
|
Write-Host "Build failed : $($buildFail.Count)" -ForegroundColor Red
|
|
$buildFail | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
|
|
}
|
|
if ($Test) {
|
|
Write-Host "Test passed : $($testPass.Count)" -ForegroundColor Green
|
|
if ($testFail.Count -gt 0) {
|
|
Write-Host "Test failed : $($testFail.Count)" -ForegroundColor Red
|
|
$testFail | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
|
|
}
|
|
}
|
|
|
|
if ($buildFail.Count -gt 0 -or $testFail.Count -gt 0) {
|
|
exit 1
|
|
}
|