@echo off
REM Build du launcher principal (PS_Launcher.exe).
REM Sortie : C:\ASTERION\GIT\PS_Launcher\PS_Launcher.exe (~78 Mo single-file self-contained)

setlocal
set "REPO=%~dp0"
echo.
echo ==^> Termine les eventuelles instances de PS_Launcher qui verrouilleraient les .exe
taskkill /F /IM PS_Launcher.exe         /T >nul 2>&1
taskkill /F /IM PS_Launcher.Updater.exe /T >nul 2>&1
echo.
echo ==^> dotnet publish PSLauncher.App (Release single-file)
echo.

dotnet publish "%REPO%src\PSLauncher.App\PSLauncher.App.csproj" -c Release --nologo
set "EXITCODE=%ERRORLEVEL%"

echo.
if %EXITCODE% NEQ 0 (
    echo [ECHEC] Build du launcher echoue avec le code %EXITCODE%.
) else (
    echo [OK] PS_Launcher.exe disponible a la racine du repo :
    echo      %REPO%PS_Launcher.exe
)
echo.
pause
endlocal ^& exit /b %EXITCODE%
