Files

97 lines
2.6 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
echo ============================================
echo Sa Polar - Compilacion MSI
echo ============================================
echo.
:: Config
set WIXBIN="%ProgramFiles(x86)%\WiX Toolset v3.11\bin"
set PROJECT_DIR=%~dp0..
set INSTALLER_DIR=%~dp0
set OUTPUT_DIR=%INSTALLER_DIR%output
set VERSION=1.0.0
set PRODUCT_WXS=%INSTALLER_DIR%Product.wxs
set LANG_WXL=%INSTALLER_DIR%Lang.wxl
set ICON_PATH=%INSTALLER_DIR%assets\sa-polar.ico
:: Clean
if exist "%OUTPUT_DIR%" rmdir /s /q "%OUTPUT_DIR%"
mkdir "%OUTPUT_DIR%"
:: Pre-compile checks
echo [1/4] Verificando archivos necesarios...
set FILES_MISSING=0
for %%F in (
"%PROJECT_DIR%\docker-compose.yml"
"%PROJECT_DIR%\.env.example"
"%PROJECT_DIR%\nginx.conf"
"%PROJECT_DIR%\Dockerfile.backend"
"%PROJECT_DIR%\Dockerfile.frontend"
"%PROJECT_DIR%\backend\src\main\resources\db\init.sql"
"%INSTALLER_DIR%\scripts\install.ps1"
"%INSTALLER_DIR%\scripts\manage-services.ps1"
"%INSTALLER_DIR%\scripts\uninstall.ps1"
"%INSTALLER_DIR%\scripts\create-shortcuts.ps1"
"%ICON_PATH%"
) do (
if not exist %%F (
echo [ERROR] No encontrado: %%F
set FILES_MISSING=1
)
)
if %FILES_MISSING%==1 (
echo.
echo ERROR: Faltan archivos necesarios.
pause
exit /b 1
)
echo Todos los archivos OK.
echo.
:: Compile .wxs to .wixobj
echo [2/4] Compilando fuente WiX...
%WIXBIN%\candle.exe -nologo -out "%OUTPUT_DIR%\Product.wixobj" -dProductVersion="%VERSION%" "%PRODUCT_WXS%"
if %ERRORLEVEL% neq 0 (
echo ERROR en la compilacion.
pause
exit /b %ERRORLEVEL%
)
echo OK.
echo.
:: Link .wixobj to .msi
echo [3/4] Generando MSI...
%WIXBIN%\light.exe -nologo -out "%OUTPUT_DIR%\SaPolar-v%VERSION%.msi" -loc "%LANG_WXL%" -ext "%WIXBIN%\\WixUIExtension.dll" -cultures:es-ES "%OUTPUT_DIR%\Product.wixobj"
if %ERRORLEVEL% neq 0 (
echo ERROR al generar MSI.
pause
exit /b %ERRORLEVEL%
)
echo OK.
echo.
:: Sign MSI (if signtool is available)
echo [4/4] Firmando instalador...
set SIGNTOOL="%ProgramFiles(x86)%\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe"
if exist "%SIGNTOOL%" (
%SIGNTOOL% sign /fd SHA256 /a "%OUTPUT_DIR%\SaPolar-v%VERSION%.msi"
if !ERRORLEVEL! equ 0 (
echo Instalador firmado correctamente.
) else (
echo [ADVERTENCIA] No se pudo firmar el instalador.
)
) else (
echo [ADVERTENCIA] signtool.exe no encontrado. El MSI no esta firmado.
)
echo.
echo ============================================
echo COMPILACION COMPLETADA!
echo Output: %OUTPUT_DIR%\SaPolar-v%VERSION%.msi
echo ============================================
echo.
pause