-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild-Safe.ps1
More file actions
78 lines (62 loc) · 2.19 KB
/
Copy pathBuild-Safe.ps1
File metadata and controls
78 lines (62 loc) · 2.19 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[CmdletBinding()]
param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[switch]$Test,
[switch]$NoRestore,
[switch]$Clean,
[switch]$Installer
)
$ErrorActionPreference = "Stop"
Write-Host "=== AiteBar Safe Build ===" -ForegroundColor Cyan
Write-Host "Configuration: $Configuration" -ForegroundColor Gray
if ($Clean) {
Write-Host "[0/3] Stopping build servers and removing generated outputs..." -ForegroundColor Yellow
& dotnet build-server shutdown
$generatedPaths = @(
".\AiteBar\bin",
".\AiteBar\obj",
".\AiteBar.Tests\bin",
".\AiteBar.Tests\obj",
".\artifacts\publish",
".\artifacts\installer"
)
foreach ($path in $generatedPaths) {
if (Test-Path -LiteralPath $path) {
Remove-Item -LiteralPath $path -Recurse -Force
}
}
}
$buildArgs = @(".\AiteBar.sln", "-c", $Configuration, "-m:1", "-p:UseSharedCompilation=false")
if ($NoRestore) {
$buildArgs += "--no-restore"
}
Write-Host "[1/3] 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/3] 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/3] Tests skipped. Pass -Test to run them." -ForegroundColor DarkYellow
}
if ($Installer) {
if ($Configuration -ne "Release") {
throw "Installer creation requires -Configuration Release."
}
Write-Host "[3/3] Building installer..." -ForegroundColor Yellow
& .\installer\Build-Installer.ps1 -Configuration $Configuration
if ($LASTEXITCODE -ne 0) {
throw "Installer build failed with exit code $LASTEXITCODE."
}
}
Write-Host "=== SAFE BUILD SUCCEEDED ===" -ForegroundColor Green