diff --git a/EnvelopeGenerator.Server/publish.bat b/EnvelopeGenerator.Server/publish.bat index b780f85a..bbbb7edd 100644 --- a/EnvelopeGenerator.Server/publish.bat +++ b/EnvelopeGenerator.Server/publish.bat @@ -1,5 +1,5 @@ @echo off -setlocal +setlocal enabledelayedexpansion echo ============================================================ echo EnvelopeGenerator.Server - Self-Contained Publish @@ -10,11 +10,38 @@ echo. REM Must be run from the solution root directory. REM This file is located under: EnvelopeGenerator.Server\ -set PROJECT=EnvelopeGenerator.Server\EnvelopeGenerator.Server.csproj -set OUTPUT=publish-output +set PROJECT=%~dp0EnvelopeGenerator.Server\EnvelopeGenerator.Server.csproj set RID=win-x64 set FRAMEWORK=net8.0 +REM ── Resolve project version from .csproj ────────────────────────────────────── +REM Reads the element directly from the .csproj XML using findstr. +REM Example: 1.1.0-beta → 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 "" "%PROJECT%"') do ( + set VERSION=%%v +) + +if "%VERSION%"=="" ( + echo [ERROR] Could not read ^ 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%" @@ -25,10 +52,6 @@ if exist "%OUTPUT%" ( echo. echo [2/3] Publishing... -echo Project : %PROJECT% -echo Output : %OUTPUT% -echo RID : %RID% -echo Framework: %FRAMEWORK% echo. dotnet publish "%PROJECT%" ^ @@ -50,36 +73,37 @@ echo [3/3] Verifying output... set PASS=1 -if not exist "%OUTPUT%\EnvelopeGenerator.Server.exe" ( +if not exist "!OUTPUT!\EnvelopeGenerator.Server.exe" ( echo [FAIL] EnvelopeGenerator.Server.exe not found! set PASS=0 -) -if not exist "%OUTPUT%\hostfxr.dll" ( +) 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 -) -if not exist "%OUTPUT%\coreclr.dll" ( +) 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 -) -if not exist "%OUTPUT%\Microsoft.Extensions.DependencyInjection.Abstractions.dll" ( +) 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 -) -if not exist "%OUTPUT%\web.config" ( +) 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" ( +if "!PASS!"=="1" ( echo. echo ============================================================ echo PUBLISH SUCCEEDED - echo Output folder: %~dp0%OUTPUT% + echo Version : !VERSION! + echo Output folder: !OUTPUT! echo ============================================================ echo. echo Next steps: - echo 1. Copy the contents of '%OUTPUT%' to the IIS application directory + 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.