@echo off chcp 65001 >nul 2>&1 setlocal EnableDelayedExpansion echo ======================================== echo PackagingMallShipper - Release Tool echo ======================================== echo. cd /d "%~dp0" set "ISCC=" set "ISCC_PATH1=C:\Program Files (x86)\Inno Setup 6\ISCC.exe" set "ISCC_PATH2=C:\Program Files\Inno Setup 6\ISCC.exe" if exist "!ISCC_PATH1!" set "ISCC=!ISCC_PATH1!" if exist "!ISCC_PATH2!" set "ISCC=!ISCC_PATH2!" if "!ISCC!"=="" ( echo [Error] Inno Setup 6 not found echo. echo Please download and install Inno Setup 6: echo https://jrsoftware.org/isdl.php echo. pause exit /b 1 ) set "CURRENT_VERSION=" for /f "tokens=3 delims=<>" %%a in ('type "PackagingMallShipper\PackagingMallShipper.csproj" ^| findstr ""') do ( set "CURRENT_VERSION=%%a" ) if "!CURRENT_VERSION!"=="" ( echo [Error] Could not read version from csproj file echo. pause exit /b 1 ) echo [Info] Current version: !CURRENT_VERSION! echo. if "%1"=="" ( echo Options: echo 1. Keep current version [!CURRENT_VERSION!] echo 2. Increment patch version echo 3. Increment minor version echo 4. Increment major version echo 5. Enter custom version echo. set /p "CHOICE=Select option [1-5]: " ) else ( set "NEW_VERSION=%1" goto :set_version ) if "!CHOICE!"=="1" ( set "NEW_VERSION=!CURRENT_VERSION!" goto :build ) if "!CHOICE!"=="2" ( call :increment_patch !CURRENT_VERSION! goto :set_version ) if "!CHOICE!"=="3" ( call :increment_minor !CURRENT_VERSION! goto :set_version ) if "!CHOICE!"=="4" ( call :increment_major !CURRENT_VERSION! goto :set_version ) if "!CHOICE!"=="5" ( set /p "NEW_VERSION=Enter new version: " goto :set_version ) set "NEW_VERSION=!CURRENT_VERSION!" goto :build :set_version echo. echo [Step 1] Updating version to !NEW_VERSION!... powershell -Command "(Get-Content 'PackagingMallShipper\PackagingMallShipper.csproj') -replace '[0-9]+\.[0-9]+\.[0-9]+', '!NEW_VERSION!' -replace '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+', '!NEW_VERSION!.0' -replace '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+', '!NEW_VERSION!.0' | Set-Content 'PackagingMallShipper\PackagingMallShipper.csproj' -Encoding UTF8" powershell -Command "(Get-Content 'setup.iss') -replace '#define MyAppVersion \"[0-9]+\.[0-9]+\.[0-9]+\"', '#define MyAppVersion \"!NEW_VERSION!\"' | Set-Content 'setup.iss' -Encoding UTF8" echo [Info] Version updated to !NEW_VERSION! echo. :build echo [Step 2] Building Release version... dotnet build -c Release if !ERRORLEVEL! NEQ 0 ( echo [Error] Build failed! pause exit /b 1 ) echo. echo [Step 3] Copying files to publish folder... if not exist "publish" mkdir publish if not exist "publish\x64" mkdir publish\x64 if not exist "publish\x86" mkdir publish\x86 copy /Y "PackagingMallShipper\bin\Release\net462\PackagingMallShipper.exe" "publish\" >nul copy /Y "PackagingMallShipper\bin\Release\net462\PackagingMallShipper.exe.config" "publish\" >nul copy /Y "PackagingMallShipper\bin\Release\net462\*.dll" "publish\" >nul copy /Y "PackagingMallShipper\bin\Release\net462\x64\SQLite.Interop.dll" "publish\x64\" >nul copy /Y "PackagingMallShipper\bin\Release\net462\x86\SQLite.Interop.dll" "publish\x86\" >nul if not exist "publish\PackagingMallShipper.exe" ( echo [Error] publish\PackagingMallShipper.exe not found echo. pause exit /b 1 ) echo [Info] Files copied to publish folder (EXE + DLLs) echo. echo [Step 4] Compiling installer... echo. "!ISCC!" setup.iss if !ERRORLEVEL! EQU 0 ( echo. echo ======================================== echo [Success] Release completed! echo. echo Version: !NEW_VERSION! echo Installer: installer\PackagingMallShipper_Setup_v!NEW_VERSION!.exe echo ======================================== echo. if exist "installer" explorer "installer" ) else ( echo. echo [Error] Installer compilation failed ) pause exit /b 0 :increment_patch for /f "tokens=1,2,3 delims=." %%a in ("%1") do ( set /a "PATCH=%%c+1" set "NEW_VERSION=%%a.%%b.!PATCH!" ) exit /b 0 :increment_minor for /f "tokens=1,2,3 delims=." %%a in ("%1") do ( set /a "MINOR=%%b+1" set "NEW_VERSION=%%a.!MINOR!.0" ) exit /b 0 :increment_major for /f "tokens=1,2,3 delims=." %%a in ("%1") do ( set /a "MAJOR=%%a+1" set "NEW_VERSION=!MAJOR!.0.0" ) exit /b 0