-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.ps1
More file actions
62 lines (54 loc) · 1.93 KB
/
build.ps1
File metadata and controls
62 lines (54 loc) · 1.93 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
#! /usr/bin/pwsh
param(
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[string]$Task,
[string[]] $FullNameFilter,
[ValidateSet('Detailed', 'Diagnostic', 'Minimal', 'None', 'Normal')]
[String] $PesterOutput
)
$ErrorActionPreference = 'Stop'
Write-Host "Build parameters: Configuration=$Configuration, Task=$Task, FullNameFilter=$($FullNameFilter -join ', '), PesterOutput=$PesterOutput" -ForegroundColor Cyan
# Helper function to build parameters for InvokeBuild
$buildparams = @{
Configuration = $Configuration
File = Join-Path $PSScriptRoot 'PwshSpectreConsole.Src' 'Scripts' 'PwshSpectreConsole.build.ps1'
Task = 'All'
Result = 'Result'
Safe = $true
}
# Ensure InvokeBuild is installed
if (-not (Get-Module -ListAvailable -Name InvokeBuild)) {
Write-Host "Installing InvokeBuild..." -ForegroundColor Yellow
Install-Module -Name InvokeBuild -Scope CurrentUser -Force -AllowClobber
}
Import-Module InvokeBuild -ErrorAction Stop
if (-not (Get-Command dotnet)) {
throw "dotnet CLI not found. Please install .NET SDK from https://dotnet.microsoft.com/download"
}
# Parse task argument
if ($task) {
$buildparams.Task = $task
}
if ($FullNameFilter) {
$buildparams['FullNameFilter'] = $FullNameFilter
}
if ($PesterOutput) {
$buildparams['PesterOutput'] = $PesterOutput
}
Write-Host "Running build with configuration: $Configuration, buildParameters: $($buildparams | ConvertTo-Json -Depth 3)"
if (-not $env:CI) {
# In local environment, run in separate PowerShell to allow rebuilds without restart
$sb = {
param($bp)
Invoke-Build @bp
}
pwsh -NoProfile -Command $sb -args $buildparams
}
else {
# In CI environment, run directly
Invoke-Build @buildparams
if ($Result.Error) {
throw "Build failed with error: $($Result.Error)"
}
}