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. "
}
2026-05-23 21:31:34 +02:00
Write-Host " version.json aus aza_version.py + _build_info.py synchronisieren... "
python -c @"
import json
from pathlib import Path
root = Path ( r '$projectRoot' )
info = { }
exec ( ( root / '_build_info.py' ) . read_text ( encoding = 'utf-8' ) , info )
from aza_version import APP_VERSION , APP_CHANNEL
payload = {
'version' : APP_VERSION ,
'build' : info . get ( 'BUILD_TIMESTAMP' , '' ) ,
'channel' : APP_CHANNEL ,
'app' : 'AZA Desktop' ,
}
( root / 'version.json' ) . write_text ( json . dumps ( payload , indent = 2 ) + '\n' , encoding = 'utf-8' )
print ( ' version.json ->' , payload [ 'version' ] , payload [ 'build' ] )
" @
2026-04-19 20:41:37 +02:00
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-05-11 08:27:44 +02:00
$distRoot = Join-Path $projectRoot " dist\aza_desktop "
Write-Host " Empfang Web-Shell (AZA_EmpfangShell.exe) bauen... "
$shellSpec = Join-Path $projectRoot " AZA_EmpfangShell.spec "
pyinstaller - -noconfirm $shellSpec
if ( $LASTEXITCODE -ne 0 ) {
Write-Error " PyInstaller Build AZA_EmpfangShell fehlgeschlagen. "
exit 1
}
$shellExeBuilt = Join-Path $projectRoot " dist\AZA_EmpfangShell.exe "
if ( -not ( Test-Path $shellExeBuilt ) ) {
Write-Error " AZA_EmpfangShell.exe nicht gefunden: $shellExeBuilt "
exit 1
}
Copy-Item $shellExeBuilt ( Join-Path $distRoot " AZA_EmpfangShell.exe " ) -Force
Write-Host " AZA_EmpfangShell.exe -> dist\aza_desktop\ kopiert "
2026-05-23 21:31:34 +02:00
Write-Host " AzA Startpanel (aza_start_panel.exe) bauen... "
$panelSpec = Join-Path $projectRoot " aza_start_panel.spec "
pyinstaller - -noconfirm $panelSpec
if ( $LASTEXITCODE -ne 0 ) {
Write-Error " PyInstaller Build aza_start_panel fehlgeschlagen. "
exit 1
}
$panelExeBuilt = Join-Path $projectRoot " dist\aza_start_panel.exe "
if ( -not ( Test-Path $panelExeBuilt ) ) {
Write-Error " aza_start_panel.exe nicht gefunden: $panelExeBuilt "
exit 1
}
Copy-Item $panelExeBuilt ( Join-Path $distRoot " aza_start_panel.exe " ) -Force
Write-Host " aza_start_panel.exe -> dist\aza_desktop\ kopiert "
Write-Host " AZA Updater (aza_updater.exe) bauen... "
$updaterSpec = Join-Path $projectRoot " aza_updater.spec "
pyinstaller - -noconfirm $updaterSpec
if ( $LASTEXITCODE -ne 0 ) {
Write-Error " PyInstaller Build aza_updater fehlgeschlagen. "
exit 1
}
$updaterExeBuilt = Join-Path $projectRoot " dist\aza_updater.exe "
if ( -not ( Test-Path $updaterExeBuilt ) ) {
Write-Error " aza_updater.exe nicht gefunden: $updaterExeBuilt "
exit 1
}
Copy-Item $updaterExeBuilt ( Join-Path $distRoot " aza_updater.exe " ) -Force
Write-Host " aza_updater.exe -> dist\aza_desktop\ kopiert "
$versionJson = Join-Path $projectRoot " version.json "
if ( Test-Path $versionJson ) {
Copy-Item $versionJson ( Join-Path $distRoot " version.json " ) -Force
Write-Host " version.json -> dist\aza_desktop\ kopiert "
}
$assetsSrc = Join-Path $projectRoot " assets "
$assetsDest = Join-Path $distRoot " assets "
if ( Test-Path $assetsSrc ) {
if ( Test-Path $assetsDest ) {
Remove-Item $assetsDest -Recurse -Force
}
Copy-Item $assetsSrc $assetsDest -Recurse -Force
Write-Host " assets\ -> dist\aza_desktop\ kopiert "
}
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
$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