@echo off
REM Decal Open Source Build Script
REM Builds all managed C# projects and the WiX installer.
REM Native C++ projects (Inject.DLL, LauncherHook.DLL) must be built separately
REM with Visual Studio 2022 or CMake (x86/Win32 target).

echo ============================================
echo  Decal Open Source Build
echo ============================================
echo.

REM Step 1: Build managed solution
echo [1/3] Building managed C# solution (25 projects)...
dotnet build Managed\Decal.sln -c Release
if errorlevel 1 (
    echo ERROR: Managed build failed.
    exit /b 1
)
echo Managed build succeeded.
echo.

REM Step 2: Build native C++ projects (requires Visual Studio 2022)
echo [2/3] Native C++ projects...
if exist "Native\build\Release\Inject.DLL" (
    echo Native DLLs already built.
) else (
    echo NOTE: Native C++ projects must be built manually:
    echo   cd Native
    echo   cmake -G "Visual Studio 17 2022" -A Win32 -B build
    echo   cmake --build build --config Release
    echo.
    echo Skipping native build for now.
)
echo.

REM Step 3: Build installer (requires WiX Toolset v5)
echo [3/3] Installer...
if exist "%USERPROFILE%\.dotnet\tools\wix.exe" (
    dotnet build Installer\Decal.Installer.wixproj -c Release ^
        -p:BuildOutput=..\Managed\bin\Release ^
        -p:NativeOutput=..\Native\build\Release
) else (
    echo NOTE: WiX Toolset not installed. Install with:
    echo   dotnet tool install --global wix
    echo Skipping installer build.
)

echo.
echo ============================================
echo  Build complete.
echo ============================================
