-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
166 lines (137 loc) · 4.45 KB
/
build.ps1
File metadata and controls
166 lines (137 loc) · 4.45 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
# EasyAppDev.Blazor.Icons Build Script
# Unified build script for Windows (PowerShell)
param(
[switch]$Regenerate,
[switch]$SkipPrompt,
[switch]$Help
)
# Exit on error
$ErrorActionPreference = "Stop"
function Write-Header {
param([string]$Message)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host $Message -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host
}
function Write-Success {
param([string]$Message)
Write-Host "✓ $Message" -ForegroundColor Green
}
function Write-Error {
param([string]$Message)
Write-Host "✗ $Message" -ForegroundColor Red
}
function Write-Warning {
param([string]$Message)
Write-Host "⚠ $Message" -ForegroundColor Yellow
}
function Write-Info {
param([string]$Message)
Write-Host "→ $Message" -ForegroundColor Yellow
}
function Check-Prerequisites {
Write-Info "Checking prerequisites..."
# Check .NET SDK
try {
$dotnetVersion = dotnet --version
Write-Success ".NET SDK found: $dotnetVersion"
}
catch {
Write-Error "Error: .NET SDK not found"
Write-Warning " Please install .NET 9 SDK from: https://dotnet.microsoft.com/download"
exit 1
}
# Check Python (optional for regeneration)
try {
$pythonVersion = python --version
Write-Success "Python found: $pythonVersion"
}
catch {
Write-Warning "Python not found (only needed for icon regeneration)"
}
Write-Host
}
function Regenerate-Icons {
Write-Info "Regenerating icon data..."
try {
$null = python --version
}
catch {
Write-Error "Python is required for icon regeneration"
exit 1
}
Push-Location src/BlazorIcons.Generator
try {
# Check if node_modules exists
if (-not (Test-Path "node_modules")) {
Write-Host " Installing npm dependencies..." -ForegroundColor Yellow
npm install
}
# Download icons
Write-Host " Downloading icons from NPM packages..." -ForegroundColor Yellow
npm run download
# Generate icon data
Write-Host " Generating icon data files..." -ForegroundColor Yellow
python generate-icons.py
Write-Success "Icon data regenerated"
Write-Host
}
finally {
Pop-Location
}
}
function Build-Solution {
Write-Info "Restoring NuGet packages..."
dotnet restore
Write-Success "Packages restored"
Write-Host
Write-Info "Building solution..."
dotnet build --configuration Release --no-restore
Write-Success "Build completed successfully"
Write-Host
}
function Show-Usage {
Write-Host "Usage: .\build.ps1 [OPTIONS]"
Write-Host
Write-Host "Options:"
Write-Host " -Regenerate Regenerate icon data before building"
Write-Host " -SkipPrompt Build without prompting for regeneration"
Write-Host " -Help Show this help message"
Write-Host
Write-Host "Examples:"
Write-Host " .\build.ps1 # Interactive build (asks about regeneration)"
Write-Host " .\build.ps1 -Regenerate # Regenerate icons and build"
Write-Host " .\build.ps1 -SkipPrompt # Quick build without regeneration"
exit 0
}
# Main execution
function Main {
if ($Help) {
Show-Usage
}
Write-Header "EasyAppDev.Blazor.Icons Build Script"
Check-Prerequisites
# Ask if user wants to regenerate icons
if ($Regenerate) {
Regenerate-Icons
}
elseif (-not $SkipPrompt) {
$response = Read-Host "Do you want to regenerate icon data before building? (y/N)"
if ($response -eq 'y' -or $response -eq 'Y') {
Regenerate-Icons
}
}
Build-Solution
Write-Header "✓ Build completed successfully!"
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host " • Run sample app: " -NoNewline -ForegroundColor White
Write-Host "dotnet run --project samples/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample.csproj" -ForegroundColor Cyan
Write-Host " • Create packages: " -NoNewline -ForegroundColor White
Write-Host "dotnet pack --configuration Release" -ForegroundColor Cyan
Write-Host " • Run tests: " -NoNewline -ForegroundColor White
Write-Host "dotnet test" -ForegroundColor Cyan
Write-Host
}
# Run main function
Main