set m=Unknown error

@echo ****************** CLEAN ALL OUTPUT FOLDERS **********
rmdir c:\data\code\sockeye\server\wwwroot /s/q
mkdir c:\data\code\sockeye\server\wwwroot
rmdir C:\data\code\sockeye\dist\installers /s/q
mkdir C:\data\code\sockeye\dist\installers


@echo ******************** BUILD CLIENT ****************************
cd c:\data\code\sockeye\client
call npm run build
IF %ERRORLEVEL% NEQ 0 (
set m=CLIENT FAILED TO BUILD
goto FAIL
)
xcopy c:\data\code\sockeye\client\dist\* C:\data\code\sockeye\server\wwwroot\ /e
IF %ERRORLEVEL% NEQ 0 (
set m=CLIENT FAILED TO COPY
goto FAIL
)



@echo ******************** BUILD PERPETUAL LINUX x64 **************************
rmdir C:\data\code\sockeye\dist\linux-x64 /s/q
mkdir C:\data\code\sockeye\dist\linux-x64
cd C:\data\code\sockeye\server\
dotnet publish -o C:\data\code\sockeye\dist\linux-x64\ -c Release -r linux-x64  --no-self-contained
IF %ERRORLEVEL% NEQ 0 (
set m=BUILD PERPETUAL LINUX x64 FAILED
goto FAIL
)



rem LINUX PERPETUAL SERVER
"C:\Program Files\7-Zip\7z.exe" a -tzip "C:\data\code\sockeye\dist\installers\sockeye-linux-x64-server.zip" "C:\data\code\sockeye\dist\linux-x64\*" -r
"C:\Program Files\7-Zip\7z.exe" a -tzip "C:\data\code\sockeye\dist\installers\sockeye-linux-x64-server.zip" "C:\data\code\sockeye\dist\assets\linux-server\config.json" 
IF %ERRORLEVEL% NEQ 0 (
set m=BUILD PERPETUAL LINUX x64 SERVER ZIP FAILED
goto FAIL
)



::Completed processing without error
goto OK

::------------------------
:FAIL
echo.
echo.
echo.
echo.
echo.
echo Error:
echo %m%
pause
goto DONE

::------------------------
:OK
echo.
echo.
echo.
echo.
echo.
@echo Completed without error
pause


:DONE