@echo off
verify # 2>nul
setlocal enableextensions enabledelayedexpansion
if errorlevel 1 goto CANT_SWITCH_ON_EXTENDED_CMD_PROCESSING
call #SETTINGS.cmd
if !errorlevel! neq 0 goto ERROR

if "%~0"=="PUBLISH.cmd" goto START
cls
echo PUBLISHING THE PROGRAM:
echo ίίίίίίίίίίίίίίίίίίίίίίί

:START
call #SETTINGS.cmd
if %errorlevel% neq 0 goto ERROR

call CLEAN_ALL.cmd
if %errorlevel% neq 0 goto ERROR

echo.
echo ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

set _publish_build_=1

call :EXEC_CMD dotnet publish -c "!#PublishConfiguration!"!#Publish_AdditionalKeys!
if !errorlevel! neq 0 goto ERROR

::==================================================================================================

:SUCCESS
if "%~0"=="PUBLISH.cmd" goto FINISH
echo.
echo άάά PUBLISH ΔΔ SUCCESS άάά
goto FINISH

:FAILURE
if "%~0"=="PUBLISH.cmd" goto ERROR
echo.
echo άάά ## PUBLISH ΔΔ FAILURE άάά
goto ERROR

::==================================================================================================

:EXEC_CMD
verify # 2>nul
setlocal enableextensions disabledelayedexpansion
if errorlevel 1 goto CANT_SWITCH_ON_SIMPLE_CMD_PROCESSING_RETURN_ERROR
echo.
echo ^>^> %* ...
%*
if %errorlevel% neq 0 goto END_LOCAL_RETURN_ERROR
goto END_LOCAL_RETURN_SUCCESS

:CANT_SWITCH_ON_SIMPLE_CMD_PROCESSING_RETURN_ERROR
echo.
echo ## Can not switch on simple command processing (without delayed expansion).
goto RETURN_ERROR

::==================================================================================================
:RESET_ERROR
set errorlevel=0
set errorlevel=
goto :EOF
::==================================================================================================
:RETURN_SUCCESS
set errorlevel=0
set errorlevel=
goto :EOF
:RETURN_ERROR
verify # 2>nul
goto :EOF
:END_LOCAL_RETURN_SUCCESS
endlocal
goto RETURN_SUCCESS
:END_LOCAL_RETURN_ERROR
endlocal
goto RETURN_ERROR
::==================================================================================================
:ERROR
if not "%~0"=="PUBLISH.cmd" (
echo 
if not "%$cmd_plain%"=="1" pause )
endlocal
verify # 2>nul
goto :EOF
:FINISH
endlocal
if not "%~0"=="PUBLISH.cmd" (
echo.
if not "%$cmd_plain%"=="1" pause )
call :RESET_ERROR
goto :EOF
::==================================================================================================
