$ErrorActionPreference = "Stop" $ScriptPath = $PSScriptRoot $MauiProjectPath = "d:\Proj\TodoList\src\TodoList.Maui" $Timestamp = Get-Date -Format "yyyy_MM_dd_HH_mm" $OutputBasePath = Join-Path $ScriptPath "PublishOutput" $MauiPublishPath = Join-Path $OutputBasePath "TodoList.Maui" $ZipFileName = "TodoList_Publish_$Timestamp.zip" $ZipFilePath = Join-Path $ScriptPath $ZipFileName Write-Host "========================================" -ForegroundColor Cyan Write-Host "TodoList Publish Script" -ForegroundColor Cyan Write-Host "Timestamp: $Timestamp" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" if (Test-Path $OutputBasePath) { Write-Host "Cleaning previous publish output..." -ForegroundColor Yellow Remove-Item $OutputBasePath -Recurse -Force } New-Item -ItemType Directory -Path $OutputBasePath -Force | Out-Null Write-Host "[Step 1/2] Publishing TodoList.Maui..." -ForegroundColor Cyan $MauiProjectFile = Join-Path $MauiProjectPath "TodoList.Maui.csproj" dotnet publish $MauiProjectFile -f net10.0-windows10.0.19041.0 -c Release --self-contained false -o $MauiPublishPath if ($LASTEXITCODE -ne 0) { Write-Error "MAUI publish failed" exit 1 } Write-Host "TodoList.Maui publish completed successfully!" -ForegroundColor Green Write-Host "" Write-Host "[Step 2/2] Creating ZIP package..." -ForegroundColor Cyan if (Test-Path $ZipFilePath) { Write-Host "Removing existing ZIP file..." -ForegroundColor Gray Remove-Item $ZipFilePath -Force } Compress-Archive -Path "$MauiPublishPath\*" -DestinationPath $ZipFilePath -Force Write-Host "ZIP package created: $ZipFilePath" -ForegroundColor Green Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host "Publish completed successfully!" -ForegroundColor Green Write-Host "Output: $ZipFilePath" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Cyan