@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%