@goto INITIALIZE
:BEGIN
::==================================================================================================
:: SETTINGS (PROPERTIES) | UTF-8 WITHOUT BOM:
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

set #ProjectName=Test
set #FrameworkFolderName=net6.0

set #ProjectFileName=!#ProjectName!.csproj
set #TargetModuleName=!#ProjectName!.exe
set #UseMsBuild=1

set #PublishPlatform=x64
set #PublishConfiguration=Release
set #PublishRID=win-x64
set #Publish_AdditionalKeys=
rem set #Publish_AdditionalKeys=!#Publish_AdditionalKeys! --self-contained
rem set #PublishPlatform=x86
rem set #PublishRID=win-x86
set #PublishDir=bin\!#PublishConfiguration!\!#FrameworkFolderName!\!#PublishRID!\publish\
set #PublishExePath=!#PublishDir!!#TargetModuleName!

set #TargetDir_D=bin\Debug\!#FrameworkFolderName!\
set #TargetDir_R=bin\Release\!#FrameworkFolderName!\

set #TargetModulePath_D=!#TargetDir_D!!#TargetModuleName!
set #TargetModulePath_R=!#TargetDir_R!!#TargetModuleName!

::--------------------------------------------------------------------------------------------------
rem set #UnicodeProperty=ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
goto :FINALIZE
::==================================================================================================
:INITIALIZE
@echo off
if not "%~0"=="#SETTINGS.cmd" goto INCORRECT_INTERNAL_CALL
call :CHECK_SETLOCAL_MODE
if %errorlevel% neq 0 goto TERMINATED
call :SAVE_CODE_PAGE
if !errorlevel! neq 0 goto TERMINATED
chcp 65001 > nul
if !errorlevel! neq 0 goto CANT_SWITCH_ON_UNICODE_CP
goto BEGIN
::--------------------------------------------------------------------------------------------------
:FINALIZE
if not defined settings_cmd_initial_cp goto SETTINGS_CMD_INITIAL_CP_NOT_DEF
call :RESET_ERROR
chcp !settings_cmd_initial_cp! > nul
if !errorlevel! neq 0 goto CANT_RESTORE_CODE_PAGE
set settings_cmd_initial_cp=
goto :EOF
::--------------------------------------------------------------------------------------------------
:CHECK_SETLOCAL_MODE
setlocal
call :RESET_ERROR
set CheckSetLocalMode_Value=
if not "!CheckSetLocalMode_Value!"=="" goto INCORRECT_SETLOCAL_MODE
goto :EOF
::--------------------------------------------------------------------------------------------------
:SAVE_CODE_PAGE
set settings_cmd_initial_cp=
for /f "tokens=*" %%s in ('"chcp"') do (
rem -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
for %%t in (%%~s) do set settings_cmd_initial_cp=%%t
if !errorlevel! neq 0 goto CANT_OBTAIN_CURRENT_CP
rem -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
)
if !errorlevel! neq 0 goto CANT_OBTAIN_CURRENT_CP
if not defined settings_cmd_initial_cp goto CANT_OBTAIN_CURRENT_CP
goto :EOF
::==================================================================================================
:INCORRECT_INTERNAL_CALL
echo.
echo ## Incorrect internal call of "%~nx0" (auxiliary batch).
goto ERROR
:INCORRECT_SETLOCAL_MODE
echo.
echo ## Incorrect mode of "setlocal"-command.
goto TERMINATED
::--------------------------------------------------------------------------------------------------
:CANT_SWITCH_ON_EXTENDED_CMD_PROCESSING
echo.
echo ## Can not switch on extended command processing.
goto TERMINATED
:CANT_SWITCH_ON_SIMPLE_CMD_PROCESSING
echo.
echo ## Can not switch on simple command processing (without delayed expansion).
goto TERMINATED
::--------------------------------------------------------------------------------------------------
:CANT_OBTAIN_CURRENT_CP
echo.
echo ## Can not obtain current code page.
goto TERMINATED
:CANT_SWITCH_ON_UNICODE_CP
echo.
echo ## Can not switch on unicode code page (UTF-8).
goto TERMINATED
:CANT_RESTORE_CODE_PAGE
echo.
echo ## Can not restore initial code page (%settings_cmd_initial_cp%).
goto TERMINATED
:SETTINGS_CMD_INITIAL_CP_NOT_DEF
echo.
echo ## Variable not defined: "settings_cmd_initial_cp".
goto TERMINATED
::--------------------------------------------------------------------------------------------------
rem :
rem echo.
rem echo ## 
rem goto TERMINATED
::==================================================================================================
:TERMINATED
echo ## CMD-execution is terminated (in "%~dpnx0").
echo 
pause
EXIT 255
::==================================================================================================
:RESET_ERROR
set errorlevel=0
set errorlevel=
goto :EOF
::==================================================================================================
:ERROR
echo 
pause
EXIT 255
::==================================================================================================
