2026-04-19 20:41:37 +02:00
Write-Host " AZA Desktop EXE Build gestartet... "
2026-03-25 22:03:39 +01:00
$projectRoot = $PSScriptRoot
$specFile = Join-Path $projectRoot " aza_desktop.spec "
Set-Location $projectRoot
2026-04-16 13:32:32 +02:00
# --- Pre-Build-Validierung: Produktivwerte pruefen ---
Write-Host " "
Write-Host " Pre-Build-Validierung... "
$urlFile = Join-Path $projectRoot " backend_url.txt "
if ( -not ( Test-Path $urlFile ) ) {
Write-Error " ABBRUCH: backend_url.txt nicht gefunden. Datei muss die produktive Backend-URL enthalten. "
exit 1
}
$urlContent = ( Get-Content $urlFile -Raw ) . Trim ( )
if ( $urlContent -match " 127\.0\.0\.1|localhost|0\.0\.0\.0 " ) {
Write-Error " ABBRUCH: backend_url.txt enthaelt eine lokale Adresse ( $urlContent ). Bitte auf die produktive URL setzen (z.B. https://api.aza-medwork.ch). "
exit 1
}
if ( -not $urlContent ) {
Write-Error " ABBRUCH: backend_url.txt ist leer. Bitte die produktive Backend-URL eintragen. "
exit 1
}
Write-Host " backend_url.txt OK: $urlContent "
$tokenFile = Join-Path $projectRoot " backend_token.txt "
if ( -not ( Test-Path $tokenFile ) ) {
Write-Error " ABBRUCH: backend_token.txt nicht gefunden. Datei muss den produktiven API-Token enthalten. "
exit 1
}
$tokenContent = ( Get-Content $tokenFile -Raw ) . Trim ( )
if ( -not $tokenContent ) {
Write-Error " ABBRUCH: backend_token.txt ist leer. Bitte den produktiven API-Token eintragen. "
exit 1
}
if ( $tokenContent -match " CHANGE_ME " ) {
Write-Error " ABBRUCH: backend_token.txt enthaelt einen Platzhalter ( $tokenContent ). Bitte den echten produktiven Token eintragen. "
exit 1
}
Write-Host " backend_token.txt OK (Token vorhanden, kein Platzhalter) "
Write-Host " "
2026-04-19 20:41:37 +02:00
Write-Host " Build-Stamp erzeugen (_build_info.py)... "
python ( Join-Path $projectRoot " aza_build_stamp.py " )
if ( $LASTEXITCODE -ne 0 ) {
Write-Warning " Build-Stamp konnte nicht erzeugt werden - fahre trotzdem fort. "
}
Write-Host " PyInstaller Installation pruefen... "
2026-03-25 22:03:39 +01:00
pip install pyinstaller - -quiet
Write-Host " Alte Build-Artefakte werden bereinigt... "
if ( Test-Path ( Join-Path $projectRoot " build " ) ) {
Remove-Item ( Join-Path $projectRoot " build " ) -Recurse -Force
}
if ( Test-Path ( Join-Path $projectRoot " dist\aza_desktop " ) ) {
Remove-Item ( Join-Path $projectRoot " dist\aza_desktop " ) -Recurse -Force
}
Write-Host " EXE wird aus aza_desktop.spec gebaut... "
pyinstaller - -noconfirm $specFile
if ( $LASTEXITCODE -ne 0 ) {
Write-Error " PyInstaller Build fehlgeschlagen. "
exit 1
}
$exePath = Join-Path $projectRoot " dist\aza_desktop\aza_desktop.exe "
if ( -not ( Test-Path $exePath ) ) {
Write-Error " Build wurde beendet, aber die EXE wurde nicht gefunden: $exePath "
exit 1
}
2026-04-16 13:32:32 +02:00
# backend_url.txt und backend_token.txt auch im dist-Root ablegen (neben der EXE),
2026-04-19 20:41:37 +02:00
# damit Installer und Runtime sie zuverlaessig finden.
2026-04-16 13:32:32 +02:00
$distRoot = Join-Path $projectRoot " dist\aza_desktop "
$internalDir = Join-Path $distRoot " _internal "
foreach ( $cfgFile in @ ( " backend_url.txt " , " backend_token.txt " ) ) {
$src = Join-Path $internalDir $cfgFile
$dst = Join-Path $distRoot $cfgFile
if ( ( Test-Path $src ) -and -not ( Test-Path $dst ) ) {
Copy-Item $src $dst -Force
Write-Host " $cfgFile -> dist\aza_desktop\ kopiert "
}
}
2026-04-19 20:41:37 +02:00
# Build-Info als lesbares Textfile neben die EXE legen
$buildInfoPy = Join-Path $projectRoot " _build_info.py "
if ( Test-Path $buildInfoPy ) {
$biDst = Join-Path $distRoot " BUILD_INFO.txt "
$biContent = Get-Content $buildInfoPy -Raw
$biContent | Out-File -FilePath $biDst -Encoding utf8
Write-Host " BUILD_INFO.txt -> dist\aza_desktop\ kopiert "
}
2026-03-25 22:03:39 +01:00
Write-Host " "
Write-Host " Build fertig. "
Write-Host " Die Desktop-App liegt in: "
2026-04-19 20:41:37 +02:00
Write-Host $distRoot
2026-03-25 22:03:39 +01:00
Write-Host " EXE: "
Write-Host $exePath