From b1e4bf4b0f5c1e9121065a6655d2b11ed2fe26cc Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 25 Dec 2025 08:48:48 +0100 Subject: [PATCH] Add interactive build_fruitbank.bat script to solution Added build_fruitbank.bat as a Solution Item. This batch script provides an interactive interface for building, cleaning, or cleaning and building the FruitBank project and related solutions. It automates cleaning bin/obj folders, runs dotnet clean/build for multiple projects, and includes special handling for AyCode.Core.sln. The script improves developer workflow with user prompts, feedback, and error handling. --- FruitBank.sln | 5 ++ build_fruitbank.bat | 127 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 build_fruitbank.bat diff --git a/FruitBank.sln b/FruitBank.sln index 7c628905..6b64d63f 100644 --- a/FruitBank.sln +++ b/FruitBank.sln @@ -91,6 +91,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.EndPoints", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.EndPoints.Tests", "Tests\Mango.Sandbox\Mango.Sandbox.EndPoints.Tests\Mango.Sandbox.EndPoints.Tests.csproj", "{B8491E5C-DBB5-1594-052E-744D78D7A4DE}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5881709D-780C-402A-9627-928B25AE712B}" + ProjectSection(SolutionItems) = preProject + build_fruitbank.bat = build_fruitbank.bat + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/build_fruitbank.bat b/build_fruitbank.bat new file mode 100644 index 00000000..5aaa81f3 --- /dev/null +++ b/build_fruitbank.bat @@ -0,0 +1,127 @@ +@echo off +setlocal enabledelayedexpansion + +cd /d "%~dp0" + +echo ================================================== +echo Build Script +echo Root: %CD% +echo ================================================== + +echo. +echo Select project: +echo 1. FruitBank +echo. +set /p projChoice="Enter choice (1, default=1): " + +if "%projChoice%"=="" set projChoice=1 +if "%projChoice%"=="1" ( + set PROJECT=FruitBank +) else ( + set PROJECT=FruitBank +) + +echo. +echo Select action: +echo 1. Build +echo 2. Clean and Build +echo 3. Clean +echo. +set /p actionChoice="Enter choice (1-3, default=1): " + +if "%actionChoice%"=="" set actionChoice=1 +if "%actionChoice%"=="1" set ACTION=Build +if "%actionChoice%"=="2" set ACTION=CleanBuild +if "%actionChoice%"=="3" set ACTION=Clean + +echo. +echo Select build configuration: +echo 1. Debug +echo 2. Release +echo. +set /p configChoice="Enter choice (1 or 2, default=1): " + +if "%configChoice%"=="2" ( + set CONFIG=Release +) else ( + set CONFIG=Debug +) + +echo. +echo ================================================== +echo Project: %PROJECT% +echo Action: %ACTION% +echo Configuration: %CONFIG% +echo ================================================== +echo. + +REM ===== CLEAN ===== +if "%ACTION%"=="CleanBuild" goto :doClean +if "%ACTION%"=="Clean" goto :doClean +goto :skipClean + +:doClean +echo Deleting bin and obj folders... +powershell -NoProfile -ExecutionPolicy Bypass -Command "$proj='%PROJECT%'; $cfg='%CONFIG%'; $specialDirs=@('Aycode\Source\AyCode.Core','Aycode\Source\AyCode.Blazor'); $normalDirs=@('Mango\Source\NopCommerce.Common','Mango\Source\FruitBank','Mango\Source\FruitBankHybridApp'); foreach($d in $specialDirs) { if(Test-Path $d) { $p=\"$d\bin\$proj\$cfg\"; if(Test-Path $p){Remove-Item $p -Recurse -Force -EA SilentlyContinue; Write-Host \"Removed: $p\"} Get-ChildItem $d -Recurse -Directory -Force -EA SilentlyContinue | Where-Object {$_.Name -eq 'obj'} | ForEach-Object {Remove-Item $_.FullName -Recurse -Force -EA SilentlyContinue; Write-Host \"Removed: $($_.FullName)\"} } }; foreach($d in $normalDirs) { if(Test-Path $d) { $p=\"$d\bin\$cfg\"; if(Test-Path $p){Remove-Item $p -Recurse -Force -EA SilentlyContinue; Write-Host \"Removed: $p\"} Get-ChildItem $d -Recurse -Directory -Force -EA SilentlyContinue | Where-Object {$_.Name -eq 'obj'} | ForEach-Object {Remove-Item $_.FullName -Recurse -Force -EA SilentlyContinue; Write-Host \"Removed: $($_.FullName)\"} } }" + +echo. +echo Running dotnet clean... +dotnet clean "Aycode\Source\AyCode.Core\AyCode.Core.sln" -c %CONFIG% -v q --nologo 2>nul +dotnet clean "Mango\Source\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" -c %CONFIG% -v q --nologo 2>nul +dotnet clean "Mango\Source\FruitBankHybridApp\FruitBank.Common.Server\FruitBank.Common.Server.csproj" -c %CONFIG% -v q --nologo 2>nul +dotnet clean "Mango\Source\FruitBank\FruitBank.sln" -c %CONFIG% -v q --nologo 2>nul +dotnet clean "Mango\Source\FruitBankHybridApp\FruitBankHybrid.sln" -c %CONFIG% -v q --nologo 2>nul + +if "%ACTION%"=="Clean" goto :success + +:skipClean + +REM ===== BUILD ===== +echo. +echo Building projects... + +REM AyCode.Core.sln - special rule: Release = Debug + Release build +if "%CONFIG%"=="Release" ( + echo Building AyCode.Core.sln [Debug]... + dotnet build "Aycode\Source\AyCode.Core\AyCode.Core.sln" -c Debug --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly + if %ERRORLEVEL% neq 0 goto :error + echo Building AyCode.Core.sln [Release]... + dotnet build "Aycode\Source\AyCode.Core\AyCode.Core.sln" -c Release --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly + if %ERRORLEVEL% neq 0 goto :error +) else ( + echo Building AyCode.Core.sln [%CONFIG%]... + dotnet build "Aycode\Source\AyCode.Core\AyCode.Core.sln" -c %CONFIG% --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly + if %ERRORLEVEL% neq 0 goto :error +) + +echo Building Mango.Nop.Core.csproj [%CONFIG%]... +dotnet build "Mango\Source\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" -c %CONFIG% --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly +if %ERRORLEVEL% neq 0 goto :error + +echo Building FruitBank.Common.Server.csproj [%CONFIG%]... +dotnet build "Mango\Source\FruitBankHybridApp\FruitBank.Common.Server\FruitBank.Common.Server.csproj" -c %CONFIG% --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly +if %ERRORLEVEL% neq 0 goto :error + +echo Building FruitBank.sln [%CONFIG%]... +dotnet build "Mango\Source\FruitBank\FruitBank.sln" -c %CONFIG% --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly +if %ERRORLEVEL% neq 0 goto :error + +echo Building FruitBankHybrid.sln [%CONFIG%]... +dotnet build "Mango\Source\FruitBankHybridApp\FruitBankHybrid.sln" -c %CONFIG% --nologo -v m /p:WarningLevel=0 /clp:ErrorsOnly +if %ERRORLEVEL% neq 0 goto :error + +:success +echo. +echo ================================================== +echo %ACTION% completed successfully (%PROJECT% - %CONFIG%). +echo ================================================== +pause +exit /b 0 + +:error +echo. +echo ================================================== +echo BUILD FAILED with exit code %ERRORLEVEL%. +echo ================================================== +pause +exit /b %ERRORLEVEL% \ No newline at end of file