Files
EnvelopeGenerator/EnvelopeGenerator.Server/publish.bat
TekH d0ddf00fc2 Use delayed expansion and enhance publish options
Updated the `publish.bat` script to use delayed expansion (`!OUTPUT!`) for the `OUTPUT` variable to ensure correct value handling in block contexts. Updated the "Removed" message to use delayed expansion for consistency.

Added two new parameters to the `dotnet publish` command:
- `-p:WasmBuildNative=true` to enable native WebAssembly builds.
- `-m:4` to set the maximum degree of parallelism to 4 for improved build performance.
2026-11-17 14:45:09 +01:00

123 lines
3.9 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
echo ============================================================
echo EnvelopeGenerator.Server - Self-Contained Publish
echo Target: win-x64 / .NET 8 / Release
echo ============================================================
echo.
REM Must be run from the solution root directory.
REM This file is located under: EnvelopeGenerator.Server\
set PROJECT=%~dp0EnvelopeGenerator.Server\EnvelopeGenerator.Server.csproj
set RID=win-x64
set FRAMEWORK=net8.0
REM ── Resolve project version from .csproj ──────────────────────────────────────
REM Reads the <Version> element directly from the .csproj XML using findstr.
REM Example: <Version>1.1.0-beta</Version> → VERSION=1.1.0-beta
REM 'tokens=2 delims=>' splits on '>' and takes the second token (the value+tag),
REM then 'delims=<' strips the closing '<' tag leaving the bare version string.
for /f "tokens=2 delims=>< " %%v in ('findstr /i "<Version>" "%PROJECT%"') do (
set VERSION=%%v
)
if "%VERSION%"=="" (
echo [ERROR] Could not read ^<Version^> from %PROJECT%. Aborting.
pause
exit /b 1
)
REM ── Output path: network share / versioned subfolder ──────────────────────────
REM Format: M:\App&Service\0 DD - Smart UP\signFLOW\Server\net8\{version}
REM Note: the '&' in the path is literal — no escaping needed inside a set "..." assignment.
set "OUTPUT=M:\App&Service\0 DD - Smart UP\signFLOW\Server\net8\%VERSION%"
echo [0/3] Resolved build parameters
echo Project : %PROJECT%
echo Version : %VERSION%
echo Output : !OUTPUT!
echo RID : %RID%
echo Framework: %FRAMEWORK%
echo.
echo [1/3] Cleaning previous publish output...
if exist "%OUTPUT%" (
rmdir /s /q "%OUTPUT%"
echo Removed: !OUTPUT!
) else (
echo Nothing to clean.
)
echo.
echo [2/3] Publishing...
echo.
dotnet publish "%PROJECT%" ^
-c Release ^
-f %FRAMEWORK% ^
--self-contained true ^
--runtime %RID% ^
-p:WasmBuildNative=true ^
-m:4 ^
-o "%OUTPUT%"
if %ERRORLEVEL% neq 0 (
echo.
echo [ERROR] Publish failed! ERRORLEVEL=%ERRORLEVEL%
pause
exit /b %ERRORLEVEL%
)
echo.
echo [3/3] Verifying output...
set PASS=1
if not exist "!OUTPUT!\EnvelopeGenerator.Server.exe" (
echo [FAIL] EnvelopeGenerator.Server.exe not found!
set PASS=0
) else ( echo [OK] EnvelopeGenerator.Server.exe )
if not exist "!OUTPUT!\hostfxr.dll" (
echo [FAIL] hostfxr.dll not found! (Not a self-contained publish?)
set PASS=0
) else ( echo [OK] hostfxr.dll )
if not exist "!OUTPUT!\coreclr.dll" (
echo [FAIL] coreclr.dll not found! (Not a self-contained publish?)
set PASS=0
) else ( echo [OK] coreclr.dll )
if not exist "!OUTPUT!\Microsoft.Extensions.DependencyInjection.Abstractions.dll" (
echo [FAIL] Microsoft.Extensions.DependencyInjection.Abstractions.dll not found!
set PASS=0
) else ( echo [OK] Microsoft.Extensions.DependencyInjection.Abstractions.dll )
if not exist "!OUTPUT!\web.config" (
echo [FAIL] web.config not found!
set PASS=0
) else ( echo [OK] web.config )
if "!PASS!"=="1" (
echo.
echo ============================================================
echo PUBLISH SUCCEEDED
echo Version : !VERSION!
echo Output folder: !OUTPUT!
echo ============================================================
echo.
echo Next steps:
echo 1. Copy the contents of the output folder to the IIS application directory
echo 2. Set the IIS Application Pool to 'No Managed Code'
echo 3. Recycle the Application Pool
echo.
) else (
echo.
echo ============================================================
echo PUBLISH COMPLETED BUT VERIFICATION FAILED
echo Review the FAIL messages above.
echo ============================================================
echo.
)
pause
endlocal