-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
115 lines (92 loc) · 3.25 KB
/
build.ps1
File metadata and controls
115 lines (92 loc) · 3.25 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
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Build script for CliCoreKit NuGet packages
.DESCRIPTION
Builds and packages CliCoreKit libraries with version management
.PARAMETER Version
The version number to use (e.g., "1.0.0", "1.2.3-beta")
.PARAMETER Configuration
Build configuration (Debug or Release). Default is Release
.PARAMETER Output
Output directory for NuGet packages. Default is ./artifacts
.PARAMETER Clean
Clean before building
.EXAMPLE
.\build.ps1 -Version "1.0.0"
.\build.ps1 -Version "1.2.0-beta" -Configuration Debug
.\build.ps1 -Version "2.0.0" -Clean
#>
param(
[Parameter(Mandatory=$false)]
[string]$Version = "1.0.0",
[Parameter(Mandatory=$false)]
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[Parameter(Mandatory=$false)]
[string]$Output = "./artifacts",
[Parameter(Mandatory=$false)]
[switch]$Clean
)
$ErrorActionPreference = "Stop"
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host " CliCoreKit Build Script" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Version: $Version" -ForegroundColor Green
Write-Host "Configuration: $Configuration" -ForegroundColor Green
Write-Host "Output: $Output" -ForegroundColor Green
Write-Host ""
# Clean if requested
if ($Clean) {
Write-Host "Cleaning..." -ForegroundColor Yellow
dotnet clean -c $Configuration
if (Test-Path $Output) {
Remove-Item $Output -Recurse -Force
}
}
# Create output directory
if (-not (Test-Path $Output)) {
New-Item -ItemType Directory -Path $Output | Out-Null
}
# Restore dependencies
Write-Host "Restoring dependencies..." -ForegroundColor Yellow
dotnet restore
# Build solution
Write-Host "Building solution..." -ForegroundColor Yellow
dotnet build -c $Configuration --no-restore /p:Version=$Version
# Run tests
Write-Host "Running tests..." -ForegroundColor Yellow
dotnet test -c $Configuration --no-build --verbosity normal
if ($LASTEXITCODE -ne 0) {
Write-Host "Tests failed!" -ForegroundColor Red
exit 1
}
# Pack Core library
Write-Host "Packing Monbsoft.CliCoreKit.Core..." -ForegroundColor Yellow
dotnet pack src/CliCoreKit.Core/CliCoreKit.Core.csproj `
-c $Configuration `
--no-build `
-o $Output `
/p:Version=$Version `
/p:PackageVersion=$Version
# Pack Hosting library
Write-Host "Packing Monbsoft.CliCoreKit.Hosting..." -ForegroundColor Yellow
dotnet pack src/CliCoreKit.Hosting/CliCoreKit.Hosting.csproj `
-c $Configuration `
--no-build `
-o $Output `
/p:Version=$Version `
/p:PackageVersion=$Version
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host " Build Completed Successfully!" -ForegroundColor Green
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Packages created in: $Output" -ForegroundColor Green
Write-Host ""
Get-ChildItem $Output -Filter "*.nupkg" | ForEach-Object {
Write-Host " - $($_.Name)" -ForegroundColor Cyan
}
Write-Host ""
Write-Host "To publish to NuGet.org:" -ForegroundColor Yellow
Write-Host " dotnet nuget push $Output\*.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json" -ForegroundColor Gray
Write-Host ""