@echo off
echo ============================================
echo  AutoIngest - Standalone Build
echo  (no .NET runtime required on target PC)
echo ============================================
echo.

REM Check for .NET 8 SDK
where dotnet >nul 2>&1
if %errorlevel% neq 0 (
    echo ERROR: .NET 8 SDK not found.
    echo Install it from: https://dotnet.microsoft.com/download/dotnet/8.0
    pause
    exit /b 1
)

echo Restoring NuGet packages...
cd /d "%~dp0AutoIngest"
dotnet restore
if %errorlevel% neq 0 (
    echo ERROR: NuGet restore failed.
    pause
    exit /b 1
)

echo.
echo Building Standalone Release...
echo (this will take a moment...)
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -o ..\publish-standalone
if %errorlevel% neq 0 (
    echo ERROR: Build failed.
    pause
    exit /b 1
)

echo.
echo ============================================
echo  BUILD SUCCESS
echo  Output: publish-standalone\AutoIngest.exe
echo  File size will be ~150-200 MB (includes everything)
echo ============================================
echo.
echo This exe runs on ANY Windows 10/11 PC - no runtime needed.
echo.
pause
