-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
98 lines (83 loc) · 3.17 KB
/
build.ps1
File metadata and controls
98 lines (83 loc) · 3.17 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
#!/usr/bin/env pwsh
# QueryPush Build Script - PowerShell
# Builds self-contained binaries for all platforms and architectures
param(
[string]$Configuration = "Release",
[string]$OutputDir = "./publish"
)
$ErrorActionPreference = "Stop"
# Define runtime identifiers for different platforms
$runtimes = @(
"win-x64",
"win-x86",
"win-arm64",
"linux-x64",
"linux-arm64",
"linux-arm",
"osx-x64",
"osx-arm64"
)
$projectPath = "./QueryPush/QueryPush.csproj"
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "QueryPush Multi-Platform Build Script" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Clean previous builds
Write-Host "Cleaning previous builds..." -ForegroundColor Yellow
if (Test-Path $OutputDir) {
Remove-Item -Recurse -Force $OutputDir
}
New-Item -ItemType Directory -Path $OutputDir | Out-Null
# Build for each runtime
foreach ($runtime in $runtimes) {
Write-Host ""
Write-Host "Building for $runtime..." -ForegroundColor Green
$outputPath = "$OutputDir/$runtime"
try {
dotnet publish $projectPath `
--configuration $Configuration `
--runtime $runtime `
--self-contained true `
--output $outputPath `
/p:PublishSingleFile=true `
/p:PublishTrimmed=false `
/p:DebugType=None `
/p:DebugSymbols=false
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] Successfully built $runtime" -ForegroundColor Green
# Get the output file size
$exeName = if ($runtime.StartsWith("win")) { "QueryPush.exe" } else { "QueryPush" }
$exePath = Join-Path $outputPath $exeName
if (Test-Path $exePath) {
$size = (Get-Item $exePath).Length / 1MB
Write-Host " Output: $exePath ($([math]::Round($size, 2)) MB)" -ForegroundColor Gray
}
# Create zip archive
Write-Host " Creating archive..." -ForegroundColor Gray
$zipPath = "$OutputDir/QueryPush-$runtime.zip"
Compress-Archive -Path "$outputPath/*" -DestinationPath $zipPath -Force
if (Test-Path $zipPath) {
$zipSize = (Get-Item $zipPath).Length / 1MB
Write-Host " Archive: $zipPath ($([math]::Round($zipSize, 2)) MB)" -ForegroundColor Gray
}
} else {
Write-Host "[FAIL] Failed to build $runtime" -ForegroundColor Red
}
}
catch {
Write-Host "[ERROR] Error building $runtime : $_" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Build Complete!" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Binaries are located in: $OutputDir" -ForegroundColor Yellow
Write-Host ""
# List all zip files
Write-Host "Created archives:" -ForegroundColor Cyan
Get-ChildItem -Path $OutputDir -Filter "*.zip" | ForEach-Object {
$zipSize = $_.Length / 1MB
Write-Host " $($_.Name) ($([math]::Round($zipSize, 2)) MB)" -ForegroundColor Gray
}
Write-Host ""