forked from maxpiva/Kaizoku.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_apps.ps1
More file actions
83 lines (65 loc) · 2.2 KB
/
build_apps.ps1
File metadata and controls
83 lines (65 loc) · 2.2 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
$backendPath = "./KaizokuBackend"
$trayPath = "./KaizokuTray"
$project = "KaizokuBackend.csproj"
$projectTray = "KaizokuTray.csproj"
$trayOutputBase = "bin/App"
# Build Backend for all targets
Push-Location $backendPath
dotnet restore $project
$runtimeIds = @("win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-arm64")
foreach ($rid in $runtimeIds) {
dotnet publish $project -c Release -r $rid
}
Pop-Location
# Build Tray as self-contained single file for all targets
Push-Location $trayPath
foreach ($rid in $runtimeIds) {
$outputPath = "$trayOutputBase/$rid"
dotnet publish $projectTray -c Release -r $rid --self-contained true `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
-p:EnableCompressionInSingleFile=true `
-p:PublishAot=false `
-p:PublishReadyToRun=false `
-p:DebugSymbols=false `
-o $outputPath
}
# Remove unneeded runtimeconfig.json
foreach ($rid in $runtimeIds) {
$jsonPath = "$trayOutputBase/$rid/KaizokuBackend.runtimeconfig.json"
if (Test-Path $jsonPath) {
Remove-Item $jsonPath -Force
}
}
$trayBaseName = "KaizokuTray"
$finalName = "Kaizoku.NET"
$version = $null
foreach ($rid in $runtimeIds) {
$outputPath = "$trayOutputBase/$rid"
$isWindows = $rid -like "win-*"
$ext = if ($isWindows) { ".exe" } else { "" }
$oldExe = Join-Path $outputPath "$trayBaseName$ext"
$newExe = Join-Path $outputPath "$finalName$ext"
# Rename Tray to Final
if (Test-Path $oldExe) {
if (Test-Path $newExe) {
Remove-Item $newExe -Force
}
Rename-Item -Path $oldExe -NewName (Split-Path $newExe -Leaf)
}
# Extract version from win-x64 only
if ($rid -eq "win-x64" -and -not $version) {
$exePath = Resolve-Path $newExe
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion
}
}
# Create ZIPs using the retrieved version
foreach ($rid in $runtimeIds) {
$outputPath = "$trayOutputBase/$rid"
$zipName = "bin/Kaizoku.NET-$rid-v$version.zip"
if (Test-Path $zipName) {
Remove-Item $zipName -Force
}
Compress-Archive -Path "$outputPath/*" -DestinationPath $zipName
}
Pop-Location