-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-release.ps1
More file actions
111 lines (94 loc) · 3.69 KB
/
build-release.ps1
File metadata and controls
111 lines (94 loc) · 3.69 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
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Build ShiftSharp release DLL and NuGet package
.DESCRIPTION
This script builds the ShiftSharp project in Release configuration,
creating the DLL and NuGet package.
.PARAMETER Clean
Clean before building
.PARAMETER SkipTests
Skip running unit tests
.EXAMPLE
.\build-release.ps1
.\build-release.ps1 -Clean
.\build-release.ps1 -SkipTests
#>
param(
[switch]$Clean,
[switch]$SkipTests
)
$ErrorActionPreference = "Stop"
# Script directory
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectPath = Join-Path $scriptDir "ShiftSharp\ShiftSharp.csproj"
$testProjectPath = Join-Path $scriptDir "TestShiftSharp\TestShiftSharp.csproj"
$outputDir = Join-Path $scriptDir "ShiftSharp\bin\Release\net8.0"
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host " ShiftSharp Release Build Script" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Clean if requested
if ($Clean) {
Write-Host "Cleaning solution..." -ForegroundColor Yellow
dotnet clean $solutionPath --configuration Release
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Host "Clean complete." -ForegroundColor Green
Write-Host ""
}
# Restore NuGet packages
Write-Host "Restoring NuGet packages..." -ForegroundColor Yellow
dotnet restore $solutionPath
if ($LASTEXITCODE -ne 0) {
Write-Host "Restore failed!" -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "Restore complete." -ForegroundColor Green
Write-Host ""
# Build in Release configuration
Write-Host "Building solution in Release configuration..." -ForegroundColor Yellow
dotnet build $solutionPath --configuration Release --no-restore
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed!" -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "Build complete." -ForegroundColor Green
Write-Host ""
# Run tests unless skipped
if (-not $SkipTests) {
Write-Host "Running unit tests..." -ForegroundColor Yellow
dotnet test $testProjectPath --configuration Release --no-build --verbosity normal
if ($LASTEXITCODE -ne 0) {
Write-Host "Tests failed!" -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "All tests passed." -ForegroundColor Green
Write-Host ""
}
# Display output information
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host " Build Summary" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
if (Test-Path $outputDir) {
$dllPath = Join-Path $outputDir "ShiftSharp.dll"
$nupkgPath = Get-ChildItem -Path (Join-Path $scriptDir "ShiftSharp\bin\Release") -Filter "*.nupkg" -Recurse | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if (Test-Path $dllPath) {
$fileInfo = Get-Item $dllPath
Write-Host "DLL Location: " -NoNewline -ForegroundColor Yellow
Write-Host $dllPath -ForegroundColor White
Write-Host "DLL Size: " -NoNewline -ForegroundColor Yellow
Write-Host "$([math]::Round($fileInfo.Length / 1KB, 2)) KB" -ForegroundColor White
Write-Host "Built: " -NoNewline -ForegroundColor Yellow
Write-Host $fileInfo.LastWriteTime -ForegroundColor White
}
if ($nupkgPath) {
Write-Host ""
Write-Host "NuGet Package: " -NoNewline -ForegroundColor Yellow
Write-Host $nupkgPath.FullName -ForegroundColor White
Write-Host "Package Size: " -NoNewline -ForegroundColor Yellow
Write-Host "$([math]::Round($nupkgPath.Length / 1KB, 2)) KB" -ForegroundColor White
}
}
Write-Host ""
Write-Host "Build completed successfully!" -ForegroundColor Green