main init
This commit is contained in:
41
Library/web/template/build.ps1
Normal file
41
Library/web/template/build.ps1
Normal file
@@ -0,0 +1,41 @@
|
||||
# Builds everything into release\:
|
||||
# {{IDENT}}.exe one self-contained file (.NET runtime + game embedded, WebView2 window)
|
||||
# {{SLUG}}.html whole game in one HTML file
|
||||
# {{SLUG}}-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 '{{SLUG}}-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 '{{IDENT}}.exe') $out -Force
|
||||
Remove-Item $pub -Recurse -Force
|
||||
$exeFile = Get-Item (Join-Path $out '{{IDENT}}.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 '{{SLUG}}-web'
|
||||
Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory $tmp | Out-Null
|
||||
Copy-Item (Join-Path $out '{{SLUG}}.html') (Join-Path $tmp 'index.html')
|
||||
Compress-Archive -Path (Join-Path $tmp 'index.html') -DestinationPath (Join-Path $out '{{SLUG}}-web.zip') -Force
|
||||
Remove-Item $tmp -Recurse -Force
|
||||
"Fertig: $(Join-Path $out '{{SLUG}}-web.zip')"
|
||||
}
|
||||
Reference in New Issue
Block a user