-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPublish-Application.ps1
More file actions
662 lines (562 loc) · 23.1 KB
/
Copy pathPublish-Application.ps1
File metadata and controls
662 lines (562 loc) · 23.1 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
<#
.SYNOPSIS
Build script for Matroska Batch Flow application with multiple distribution modes.
.DESCRIPTION
Builds the application in various configurations for different distribution methods:
- SingleFile: Self-contained single executable (unpackaged, WinUI3)
- MultiFile: Multi-file deployment (unpackaged, WinUI3)
- Store: MSIX package for Microsoft Store submission
- SelfSigned: MSIX package with self-signed certificate for sideloading
- SkiaDesktopWin: Skia Desktop single-file for Windows (Experimental)
- SkiaDesktopLinux: Skia Desktop single-file for Linux (Experimental)
- SkiaDesktopWinMulti: Skia Desktop multi-file for Windows (Experimental)
- SkiaDesktopLinuxMulti: Skia Desktop multi-file for Linux (Experimental)
.PARAMETER BuildType
The type of build to create. Valid values: SingleFile, MultiFile, Store, SelfSigned, SkiaDesktopWin, SkiaDesktopLinux, SkiaDesktopWinMulti, SkiaDesktopLinuxMulti
.PARAMETER Configuration
Build configuration. Valid values: Debug, Release (default: Release)
.PARAMETER Platform
Target platform. Valid values: x64 (default: x64)
.PARAMETER OutputPath
Optional custom output directory. If not specified, uses default project output paths.
.PARAMETER Clean
Clean the build output before building.
.PARAMETER SkipRestore
Skip NuGet package restore step.
.EXAMPLE
.\Publish-Application.ps1 -BuildType Store
Builds a Release MSIX package for Microsoft Store
.EXAMPLE
.\Publish-Application.ps1 -BuildType SingleFile -Configuration Debug
Builds a Debug single-file executable
.EXAMPLE
.\Publish-Application.ps1 -BuildType MultiFile -Clean
Cleans and builds a Release multi-file deployment
.NOTES
Author: Tim Gels
Designed for the Matroska Batch Flow CI/CD pipelines and local development
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, Position = 0)]
[ValidateSet('SingleFile', 'MultiFile', 'Store', 'SelfSigned', 'SkiaDesktopWin', 'SkiaDesktopLinux', 'SkiaDesktopWinMulti', 'SkiaDesktopLinuxMulti')]
[string]$BuildType,
[Parameter(Mandatory = $false)]
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[Parameter(Mandatory = $false)]
[ValidateSet('x64')]
[string]$Platform = 'x64',
[Parameter(Mandatory = $false)]
[string]$OutputPath,
[Parameter(Mandatory = $false)]
[switch]$Clean,
[Parameter(Mandatory = $false)]
[switch]$SkipRestore
)
$ErrorActionPreference = 'Stop'
# ═══════════════════════════════════════════════════════════════
# Constants
# ═══════════════════════════════════════════════════════════════
$BORDER_LINE = "═══════════════════════════════════════════════════════════════"
$DOTNET_COMMON_ARGS = @('--nologo', '-v', 'minimal')
$FRAMEWORK_SKIA_DESKTOP = 'net10.0-desktop'
$FRAMEWORK_WINAPPSDK = 'net10.0-windows10.0.19041'
# ═══════════════════════════════════════════════════════════════
# Platform Validation
# ═══════════════════════════════════════════════════════════════
# Verify running on Windows
if (-not $IsWindows -and -not ($PSVersionTable.PSVersion.Major -le 5)) {
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Red
Write-Host ""
Write-Host " ✗ PLATFORM NOT SUPPORTED" -ForegroundColor Red
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Red
Write-Host ""
Write-Host " This script builds Windows applications (WinUI3/MSIX) and must run on Windows." -ForegroundColor Yellow
Write-Host ""
Write-Host " Current platform: $($PSVersionTable.Platform)" -ForegroundColor Gray
Write-Host ""
Write-Host " For CI/CD pipelines:" -ForegroundColor Cyan
Write-Host " • Use a Windows runner (e.g., runs-on: windows-latest)" -ForegroundColor Gray
Write-Host " • Or use a Windows container" -ForegroundColor Gray
Write-Host ""
Write-Host " This script cannot build Windows apps on Linux/macOS." -ForegroundColor Yellow
Write-Host ""
exit 1
}
# ═══════════════════════════════════════════════════════════════
# Configuration
# ═══════════════════════════════════════════════════════════════
# Script paths
$ProjectPath = Join-Path $PSScriptRoot 'src' 'MatroskaBatchFlow.Uno' 'MatroskaBatchFlow.Uno.csproj'
# Verify project file exists
if (-not (Test-Path $ProjectPath)) {
Write-Error "Project file not found: $ProjectPath"
exit 1
}
# Build type configurations
$BuildConfigs = @{
SingleFile = @{
DisplayName = 'Single-File Executable (Unpackaged)'
PublishProfile = 'win-x64-singlefile'
TargetFramework = $FRAMEWORK_WINAPPSDK
UsePublish = $true
OutputPattern = '*.exe'
OutputDescription = 'Single executable ready for distribution'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\publish\win-{Platform}-singlefile'
}
MultiFile = @{
DisplayName = 'Multi-File Deployment (Unpackaged)'
PublishProfile = 'win-x64'
TargetFramework = $FRAMEWORK_WINAPPSDK
UsePublish = $true
OutputPattern = 'MatroskaBatchFlow.exe'
OutputDescription = 'Multi-file application with separate dependencies'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\publish\win-{Platform}-multifile'
}
Store = @{
DisplayName = 'Microsoft Store MSIX Package'
TargetFramework = $FRAMEWORK_WINAPPSDK
UsePublish = $false
UseMSBuild = $true
OutputPattern = '*.msix'
OutputDescription = 'Unsigned MSIX package for Store upload'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\{Platform}\{Configuration}\{Framework}\win-{Platform}\AppPackages'
MSBuildProperties = @{
UapAppxPackageBuildMode = 'StoreUpload'
AppxBundle = 'Never'
GenerateAppxPackageOnBuild = 'true'
AppxPackageSigningEnabled = 'false'
}
}
SelfSigned = @{
DisplayName = 'Self-Signed MSIX Package'
TargetFramework = $FRAMEWORK_WINAPPSDK
UsePublish = $false
UseMSBuild = $true
OutputPattern = '*.msix'
OutputDescription = 'Self-signed MSIX package for sideloading'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\{Platform}\{Configuration}\{Framework}\win-{Platform}\AppPackages'
MSBuildProperties = @{
UapAppxPackageBuildMode = 'SideloadOnly'
AppxBundle = 'Never'
GenerateAppxPackageOnBuild = 'true'
AppxPackageSigningEnabled = 'true'
}
}
SkiaDesktopWin = @{
DisplayName = 'Skia Desktop Single-File (Windows) - EXPERIMENTAL'
PublishProfile = 'skia-desktop-win-x64'
TargetFramework = $FRAMEWORK_SKIA_DESKTOP
UsePublish = $true
OutputPattern = '*.exe'
OutputDescription = 'Experimental Skia Desktop build for Windows'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\publish\skia-win-{Platform}'
Experimental = $true
}
SkiaDesktopLinux = @{
DisplayName = 'Skia Desktop Single-File (Linux) - EXPERIMENTAL'
PublishProfile = 'skia-desktop-linux-x64'
TargetFramework = $FRAMEWORK_SKIA_DESKTOP
UsePublish = $true
OutputPattern = 'MatroskaBatchFlow'
OutputDescription = 'Experimental Skia Desktop build for Linux'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\publish\skia-linux-{Platform}'
Experimental = $true
}
SkiaDesktopWinMulti = @{
DisplayName = 'Skia Desktop Multi-File (Windows) - EXPERIMENTAL'
PublishProfile = 'skia-desktop-win-x64-multi'
TargetFramework = $FRAMEWORK_SKIA_DESKTOP
UsePublish = $true
OutputPattern = 'MatroskaBatchFlow.exe'
OutputDescription = 'Experimental Skia Desktop multi-file build for Windows'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\publish\skia-win-{Platform}-multi'
Experimental = $true
}
SkiaDesktopLinuxMulti = @{
DisplayName = 'Skia Desktop Multi-File (Linux) - EXPERIMENTAL'
PublishProfile = 'skia-desktop-linux-x64-multi'
TargetFramework = $FRAMEWORK_SKIA_DESKTOP
UsePublish = $true
OutputPattern = 'MatroskaBatchFlow'
OutputDescription = 'Experimental Skia Desktop multi-file build for Linux'
DefaultOutputPath = 'src\MatroskaBatchFlow.Uno\bin\publish\skia-linux-{Platform}-multi'
Experimental = $true
}
}
# ═══════════════════════════════════════════════════════════════
# Helper Functions
# ═══════════════════════════════════════════════════════════════
function Format-FileSize {
<#
.SYNOPSIS
Converts bytes to human-readable file size format.
.DESCRIPTION
Automatically selects the appropriate unit (GB, MB, KB, bytes) based on file size.
Returns a formatted string with 2 decimal places for non-byte values.
.EXAMPLE
Format-FileSize -Bytes 1073741824 # Returns "1 GB"
#>
param(
[Parameter(Mandatory = $true)]
[long]$Bytes
)
# Size definitions (easy to extend with TB, PB, etc.)
$sizes = @(
@{ Unit = 'GB'; Divisor = 1GB; Threshold = 1GB }
@{ Unit = 'MB'; Divisor = 1MB; Threshold = 1MB }
@{ Unit = 'KB'; Divisor = 1KB; Threshold = 1KB }
)
# Iterate through sizes and return the first matching unit.
foreach ($size in $sizes) {
if ($Bytes -ge $size.Threshold) {
$value = [math]::Round($Bytes / $size.Divisor, 2)
return "$value $($size.Unit)"
}
}
return "$Bytes bytes"
}
function Write-Header {
<#
.SYNOPSIS
Displays a formatted header with build information.
#>
param(
[string]$Title,
[hashtable]$BuildInfo
)
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Cyan
Write-Host ""
Write-Host " $Title" -ForegroundColor White
Write-Host ""
Write-Host " ───────────────────────────────────────────────────────────────" -ForegroundColor DarkCyan
Write-Host ""
foreach ($key in $BuildInfo.Keys | Sort-Object) {
$label = $key.PadRight(14)
Write-Host " $label" -NoNewline -ForegroundColor Gray
Write-Host $BuildInfo[$key] -ForegroundColor White
}
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Cyan
Write-Host ""
}
function Write-StatusMessage {
<#
.SYNOPSIS
Displays a status message with consistent formatting.
#>
param(
[string]$Message,
[ValidateSet('Info', 'Success', 'Error')]
[string]$Type = 'Info'
)
$color = switch ($Type) {
'Info' { 'Yellow' }
'Success' { 'Green' }
'Error' { 'Red' }
}
Write-Host " $Message" -ForegroundColor $color
Write-Host ""
}
function Write-BuildResult {
<#
.SYNOPSIS
Displays build success or failure with formatted output.
#>
param(
[Parameter(Mandatory)]
[bool]$Success,
[Parameter(Mandatory)]
[AllowEmptyString()]
[string]$OutputLocation,
[Parameter(Mandatory)]
[string]$OutputPattern,
[Parameter(Mandatory)]
[string]$Description,
[Parameter(Mandatory)]
[string]$BuildType
)
Write-Host ""
if ($Success) {
Write-Host " $BORDER_LINE" -ForegroundColor Green
Write-Host ""
Write-Host " ✓ BUILD SUCCEEDED" -ForegroundColor Green
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Green
Write-Host ""
Show-BuildOutput -OutputLocation $OutputLocation -OutputPattern $OutputPattern `
-Description $Description -BuildType $BuildType
}
else {
Write-Host " $BORDER_LINE" -ForegroundColor Red
Write-Host ""
Write-Host " ✗ BUILD FAILED" -ForegroundColor Red
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Red
Write-Host ""
Write-Host " Check the build output above for errors" -ForegroundColor Yellow
Write-Host ""
}
}
function Show-BuildOutput {
<#
.SYNOPSIS
Displays information about build output files.
#>
param(
[string]$OutputLocation,
[string]$OutputPattern,
[string]$Description,
[string]$BuildType
)
if (-not $OutputLocation -or -not (Test-Path $OutputLocation)) {
Write-Host " Output location not found or inaccessible" -ForegroundColor Yellow
Write-Host " Expected: $OutputLocation" -ForegroundColor Gray
Write-Host ""
return
}
Write-Host " Output Location" -ForegroundColor Cyan
Write-Host ""
Write-Host " $OutputLocation" -ForegroundColor White
Write-Host ""
$outputFiles = Get-ChildItem -Path $OutputLocation -Recurse -Include $OutputPattern -ErrorAction SilentlyContinue
if (-not $outputFiles) {
Write-Host " No output files matching '$OutputPattern' found" -ForegroundColor Yellow
Write-Host " Check the output directory for build artifacts" -ForegroundColor Gray
Write-Host ""
return
}
Write-Host " Output Files" -ForegroundColor Cyan
Write-Host ""
foreach ($file in $outputFiles) {
$sizeText = Format-FileSize -Bytes $file.Length
Write-Host " • " -NoNewline -ForegroundColor DarkGray
Write-Host $file.Name -ForegroundColor White -NoNewline
Write-Host " ($sizeText)" -ForegroundColor Gray
Write-Host " $($file.FullName)" -ForegroundColor DarkGray
}
Write-Host ""
Write-Host " $Description" -ForegroundColor Yellow
Write-Host ""
# Build-type-specific messages
switch ($BuildType) {
'Store' {
Write-Host " Upload to Microsoft Partner Center for certification" -ForegroundColor Cyan
Write-Host ""
}
'SelfSigned' {
Write-Host " Install the certificate before sideloading the package" -ForegroundColor Cyan
Write-Host ""
}
}
}
function Invoke-DotNetCommand {
<#
.SYNOPSIS
Executes a dotnet command and returns success status.
.DESCRIPTION
Runs dotnet with specified arguments. Output is streamed directly to console.
Returns $true if exit code is 0, $false otherwise.
Sets $LASTEXITCODE to the process exit code for caller use.
#>
param(
[string[]]$Arguments,
[string]$OperationName
)
Write-Verbose "Executing: dotnet $($Arguments -join ' ')"
# Start process to preserve color output
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = 'dotnet'
foreach ($arg in $Arguments) {
[void]$psi.ArgumentList.Add($arg)
}
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $false
$psi.RedirectStandardError = $false
$process = [System.Diagnostics.Process]::Start($psi)
$process.WaitForExit()
# Set LASTEXITCODE so caller can use it for error messages and exit codes
$global:LASTEXITCODE = $process.ExitCode
return ($process.ExitCode -eq 0)
}
function Remove-DebugSymbols {
<#
.SYNOPSIS
Removes debug symbol files (.pdb) from publish output.
.DESCRIPTION
Cleans up .pdb files from NuGet package dependencies that get copied to the publish directory.
These files are useful during development but not needed for distribution.
.PARAMETER OutputPath
The directory to search for .pdb files.
.EXAMPLE
Remove-DebugSymbols -OutputPath "bin\publish\win-x64"
#>
param(
[Parameter(Mandatory = $true)]
[string]$OutputPath
)
if (-not (Test-Path $OutputPath)) {
return
}
$pdbFiles = Get-ChildItem -Path $OutputPath -Filter "*.pdb" -Recurse -ErrorAction SilentlyContinue
if ($pdbFiles) {
Write-Host ""
Write-StatusMessage "Removing debug symbol files..." -Type Info
$pdbFiles | Remove-Item -Force -ErrorAction SilentlyContinue
Write-Host ""
}
}
function Resolve-BuildOutputPath {
<#
.SYNOPSIS
Resolves the output path for build artifacts using template placeholders.
#>
param(
[Parameter(Mandatory)]
[hashtable]$Config,
[Parameter(Mandatory)]
[string]$Platform,
[string]$Configuration,
[string]$Framework,
[string]$CustomOutputPath
)
if ($CustomOutputPath) {
return $CustomOutputPath
}
$path = $Config.DefaultOutputPath -replace '\{Platform\}', $Platform
if ($Configuration) {
$path = $path -replace '\{Configuration\}', $Configuration
}
if ($Framework) {
$path = $path -replace '\{Framework\}', $Framework
}
return Join-Path $PSScriptRoot $path
}
function Invoke-DotNetBuildStep {
<#
.SYNOPSIS
Executes a dotnet build step with error handling and consistent messaging.
#>
param(
[Parameter(Mandatory)]
[string]$StepName,
[Parameter(Mandatory)]
[string[]]$Arguments
)
Write-StatusMessage "$StepName..." -Type Info
if (-not (Invoke-DotNetCommand -Arguments $Arguments -OperationName $StepName)) {
Write-StatusMessage "$StepName failed with exit code $LASTEXITCODE" -Type Error
exit $LASTEXITCODE
}
Write-StatusMessage "$StepName completed" -Type Success
}
# ═══════════════════════════════════════════════════════════════
# Main Execution
# ═══════════════════════════════════════════════════════════════
try {
$config = $BuildConfigs[$BuildType]
$TargetFramework = $config.TargetFramework
# Display build information
Write-Header -Title $config.DisplayName -BuildInfo @{
Configuration = $Configuration
Platform = $Platform
Framework = $TargetFramework
}
# Display experimental warning if applicable
if ($config.Experimental) {
Write-Host ""
Write-Host " ⚠ WARNING: This is an EXPERIMENTAL build type" -ForegroundColor Yellow
Write-Host " • Not officially supported" -ForegroundColor Gray
Write-Host " • Expect bugs and compatibility issues" -ForegroundColor Gray
Write-Host ""
}
# Clean if requested
if ($Clean) {
$cleanArgs = @('clean', $ProjectPath, '-c', $Configuration) + $DOTNET_COMMON_ARGS
Invoke-DotNetBuildStep -StepName 'Cleaning previous build outputs' -Arguments $cleanArgs
}
# Restore packages unless skipped
if (-not $SkipRestore) {
$restoreArgs = @('restore', $ProjectPath) + $DOTNET_COMMON_ARGS
Invoke-DotNetBuildStep -StepName 'Restoring NuGet packages' -Arguments $restoreArgs
}
# Build based on type
$success = $false
$outputLocation = $null
if ($config.UsePublish) {
# Publish-based builds (SingleFile, MultiFile)
Write-StatusMessage "Publishing application..." -Type Info
$publishArgs = @(
'publish',
$ProjectPath,
"-p:PublishProfile=$($config.PublishProfile)",
'-c',
$Configuration,
'-f',
$TargetFramework
) + $DOTNET_COMMON_ARGS
if ($OutputPath) {
$publishArgs += '-o', $OutputPath
}
$success = Invoke-DotNetCommand -Arguments $publishArgs -OperationName 'Publish'
# Determine output location
$outputLocation = Resolve-BuildOutputPath -Config $config -Platform $Platform -CustomOutputPath $OutputPath
# Clean up debug symbols from publish output
if ($success -and $outputLocation) {
Remove-DebugSymbols -OutputPath $outputLocation
}
}
elseif ($config.UseMSBuild) {
# MSBuild-based builds (Store, SelfSigned)
Write-StatusMessage "Building MSIX package..." -Type Info
$msbuildArgs = @(
'msbuild',
$ProjectPath,
'/t:Build',
"/p:Configuration=$Configuration",
"/p:Platform=$Platform",
"/p:TargetFramework=$TargetFramework",
'/nologo',
'/v:minimal'
)
# Add build-type-specific properties
foreach ($prop in $config.MSBuildProperties.GetEnumerator()) {
$msbuildArgs += "/p:$($prop.Key)=$($prop.Value)"
}
if ($OutputPath) {
$msbuildArgs += "/p:AppxPackageDir=`"$OutputPath\`""
}
$success = Invoke-DotNetCommand -Arguments $msbuildArgs -OperationName 'Build'
# Determine output location
$outputLocation = Resolve-BuildOutputPath -Config $config -Platform $Platform -Configuration $Configuration -Framework $TargetFramework -CustomOutputPath $OutputPath
}
# Display results
Write-BuildResult `
-Success:$success `
-OutputLocation $outputLocation `
-OutputPattern $config.OutputPattern `
-Description $config.OutputDescription `
-BuildType $BuildType
if ($success) {
exit 0
}
else {
exit 1
}
}
catch {
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Red
Write-Host ""
Write-Host " ✗ BUILD FAILED WITH EXCEPTION" -ForegroundColor Red
Write-Host ""
Write-Host " $BORDER_LINE" -ForegroundColor Red
Write-Host ""
Write-Error $_.Exception.Message
Write-Host ""
exit 1
}