Files
xsl-validator/build_msi.py
T

71 lines
2.0 KiB
Python
Raw Normal View History

"""
WiX MSI Build-Skript für DocuMentor (WiX v6)
Erstellt einen MSI-Installer aus dem PyInstaller Build.
"""
import subprocess
import sys
import tomllib
from pathlib import Path
def get_version(project_root: Path) -> str:
"""Liest die Versionsnummer aus pyproject.toml."""
pyproject_path = project_root / "pyproject.toml"
with pyproject_path.open("rb") as f:
data = tomllib.load(f)
return data["project"]["version"]
def build_msi():
"""Erstellt MSI-Installer mit WiX v6."""
project_root = Path(__file__).parent
dist_dir = project_root / "dist" / "DocuMentor"
if not dist_dir.exists():
print("FEHLER: PyInstaller Build nicht gefunden!")
print("Bitte zuerst ausführen: uv run python build_windows.py")
sys.exit(1)
version = get_version(project_root)
msi_output = project_root / "dist" / f"DocuMentor-{version}.msi"
print(f"DocuMentor Build gefunden: {dist_dir}")
print(f"Version: {version}")
print(f"MSI-Ausgabe: {msi_output}")
print()
# Schritt 1: ProductFiles.wxs generieren (ersetzt WiX heat)
print("Schritt 1/2: Generiere ProductFiles.wxs...")
result = subprocess.run(["uv", "run", "python", "generate_wix_files.py"], check=False)
if result.returncode != 0:
print("\nFEHLER: ProductFiles.wxs Generierung fehlgeschlagen!")
sys.exit(1)
print()
# Schritt 2: MSI kompilieren mit WiX v6
print("Schritt 2/2: Kompiliere MSI-Installer...")
result = subprocess.run(
["wix", "build", "DocuMentor.wxs", "ProductFiles.wxs", "-o", str(msi_output)],
check=False,
)
if result.returncode != 0:
print("\nFEHLER: MSI-Kompilierung fehlgeschlagen!")
print("Stelle sicher, dass WiX v6 installiert ist:")
print(" dotnet tool install --global wix --version 6.*")
sys.exit(1)
print()
print(f"[OK] MSI erfolgreich erstellt: {msi_output}")
print()
print("Installation testen mit:")
print(f" msiexec /i \"{msi_output}\"")
if __name__ == "__main__":
build_msi()