42 lines
2.2 KiB
PowerShell
42 lines
2.2 KiB
PowerShell
|
|
# Builds everything into release\:
|
||
|
|
# RobotClash.exe one self-contained file (.NET runtime + game embedded, WebView2 window)
|
||
|
|
# robotclash.html whole game in one HTML file
|
||
|
|
# robotclash-web.zip upload package for itch.io & co (the page as index.html)
|
||
|
|
# Needs .NET 8+ SDK and Node. The PC running the exe needs the Edge WebView2 Runtime (Win 10/11 has it).
|
||
|
|
# .\build.ps1 all .\build.ps1 -Web only HTML + zip .\build.ps1 -Exe only exe
|
||
|
|
param([switch]$Web, [switch]$Exe)
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
$root = $PSScriptRoot
|
||
|
|
$out = Join-Path $root 'release'
|
||
|
|
if (-not $Web -and -not $Exe) { $Web = $true; $Exe = $true }
|
||
|
|
New-Item -ItemType Directory -Force $out | Out-Null
|
||
|
|
|
||
|
|
if ($Exe) {
|
||
|
|
# app icon from game\assets\Sprites\icon.png (once; delete launcher\app.ico to redo)
|
||
|
|
$ico = Join-Path $root 'launcher\app.ico'
|
||
|
|
$png = Join-Path $root 'game\assets\Sprites\icon.png'
|
||
|
|
if (-not (Test-Path $ico) -and (Test-Path $png)) {
|
||
|
|
py -3.12 -c "import sys; from PIL import Image; Image.open(sys.argv[1]).convert('RGBA').save(sys.argv[2], sizes=[(16,16),(24,24),(32,32),(48,48),(64,64),(128,128),(256,256)])" $png $ico
|
||
|
|
}
|
||
|
|
$pub = Join-Path $env:TEMP 'robotclash-publish'
|
||
|
|
Remove-Item $pub -Recurse -Force -ErrorAction SilentlyContinue
|
||
|
|
dotnet publish (Join-Path $root 'launcher\Launcher.csproj') -c Release -o $pub --nologo
|
||
|
|
if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed ($LASTEXITCODE)" }
|
||
|
|
Copy-Item (Join-Path $pub 'RobotClash.exe') $out -Force
|
||
|
|
Remove-Item $pub -Recurse -Force
|
||
|
|
$exeFile = Get-Item (Join-Path $out 'RobotClash.exe')
|
||
|
|
"Fertig: $($exeFile.FullName) ($([math]::Round($exeFile.Length / 1MB, 1)) MB)"
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($Web) {
|
||
|
|
node (Join-Path $root 'build-web.mjs')
|
||
|
|
if ($LASTEXITCODE -ne 0) { throw "web build failed ($LASTEXITCODE)" }
|
||
|
|
$tmp = Join-Path $env:TEMP 'robotclash-web'
|
||
|
|
Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
|
||
|
|
New-Item -ItemType Directory $tmp | Out-Null
|
||
|
|
Copy-Item (Join-Path $out 'robotclash.html') (Join-Path $tmp 'index.html')
|
||
|
|
Compress-Archive -Path (Join-Path $tmp 'index.html') -DestinationPath (Join-Path $out 'robotclash-web.zip') -Force
|
||
|
|
Remove-Item $tmp -Recurse -Force
|
||
|
|
"Fertig: $(Join-Path $out 'robotclash-web.zip')"
|
||
|
|
}
|