python-toolbox/prod_tools/messenger-wrapper/build_app.ps1

33 lines
1.3 KiB
PowerShell

Write-Host "Building Messenger Wrapper..."
# Ensure PyInstaller is installed
if (-not (Get-Command pyinstaller -ErrorAction SilentlyContinue)) {
Write-Host "PyInstaller not found. Installing..."
pip install pyinstaller
}
# Clean previous builds
Write-Host "Cleaning up..."
# Kill running instances if any
Get-Process -Name "MessengerWrapper" -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 1
if (Test-Path "dist") {
Remove-Item -Recurse -Force "dist" -ErrorAction Stop
}
if (Test-Path "build") { Remove-Item -Recurse -Force "build" }
if (Test-Path "MessengerWrapper.spec") { Remove-Item -Force "MessengerWrapper.spec" }
# Build the executable
# --noconfirm: overwrite output directory without asking
# --onefile: bundle everything into a single exe
# --windowed: no console window
# --icon: use the ico file for the exe icon
# --add-data: include the png and ico files (windows separator is ;)
# --hidden-import: ensure pythonnet/clr is available for Edge WebView2
pyinstaller --noconfirm --onefile --windowed --icon "messenger_icon.ico" --add-data "messenger_icon.png;." --add-data "messenger_icon.ico;." --hidden-import "clr" --hidden-import "System" --hidden-import "System.Windows.Forms" --name "MessengerWrapper" messenger_app.py
Write-Host "Build complete. Executable is in dist/MessengerWrapper.exe"