diff --git a/CirnoBuild.psm1 b/CirnoBuild.psm1 index 6cb98382..4ebefd4a 100644 --- a/CirnoBuild.psm1 +++ b/CirnoBuild.psm1 @@ -125,16 +125,20 @@ function Initialize-BuildDirectories { Write-Host "Initializing build directories..." -ForegroundColor Cyan - if (Test-Path $BuildDir) { - Remove-Item "$BuildDir\*" -Recurse -Force -ErrorAction SilentlyContinue - } else { + # Ensure the root build directory exists but DO NOT delete its contents (preserve logs and zips) + if (-not (Test-Path $BuildDir)) { New-Item -ItemType Directory -Path $BuildDir | Out-Null } foreach ($platform in $PlatformsToBuild) { $platformDir = Join-Path $BuildDir $script:platforms[$platform].OutputSubDir - New-Item -ItemType Directory -Path $platformDir -Force | Out-Null - Write-Host " Created: $platformDir" -ForegroundColor Gray + if (Test-Path $platformDir) { + # Clear only the platform directory contents + Remove-Item "$platformDir\*" -Recurse -Force -ErrorAction SilentlyContinue + } else { + New-Item -ItemType Directory -Path $platformDir -Force | Out-Null + } + Write-Host " Prepared: $platformDir" -ForegroundColor Gray } } @@ -254,7 +258,7 @@ function Create-PlatformZip { # Create zip Write-Host " Creating zip archive: $zipFileName" -ForegroundColor Cyan try { - if (Test-Path $zipFilePath) { Remove-Item $zipFilePath -Force } + # Do not explicitly delete existing zip to avoid losing historical artifacts; Compress-Archive -Force will overwrite Compress-Archive -Path "$platformDir\*" -DestinationPath $zipFilePath -Force Write-Host " Zip created: $zipFilePath" -ForegroundColor Green return $zipFilePath