-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild-Safe.ps1
More file actions
42 lines (33 loc) · 1.26 KB
/
Copy pathBuild-Safe.ps1
File metadata and controls
42 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[CmdletBinding()]
param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[switch]$Test,
[switch]$NoRestore
)
$ErrorActionPreference = "Stop"
Write-Host "=== AiteBar Safe Build ===" -ForegroundColor Cyan
Write-Host "Configuration: $Configuration" -ForegroundColor Gray
$buildArgs = @(".\AiteBar.sln", "-c", $Configuration, "-m:1", "-p:UseSharedCompilation=false")
if ($NoRestore) {
$buildArgs += "--no-restore"
}
Write-Host "[1/2] Building solution with serialized MSBuild and disabled shared compilation..." -ForegroundColor Yellow
& dotnet build @buildArgs
if ($LASTEXITCODE -ne 0) {
throw "dotnet build failed with exit code $LASTEXITCODE."
}
if ($Test) {
Write-Host "[2/2] Running tests from the built DLL..." -ForegroundColor Yellow
$testDll = ".\AiteBar.Tests\bin\$Configuration\net10.0-windows\AiteBar.Tests.dll"
if (-not (Test-Path -LiteralPath $testDll)) {
throw "Test assembly was not found: $testDll"
}
& dotnet vstest $testDll
if ($LASTEXITCODE -ne 0) {
throw "dotnet vstest failed with exit code $LASTEXITCODE."
}
} else {
Write-Host "[2/2] Tests skipped. Pass -Test to run them." -ForegroundColor DarkYellow
}
Write-Host "=== SAFE BUILD SUCCEEDED ===" -ForegroundColor Green