[CmdletBinding()] param( [switch]$Restore, [switch]$Clean, [switch]$StopRunningApp ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $MyInvocation.MyCommand.Path $project = Join-Path $root "src\AxCopilot\AxCopilot.csproj" $assetsFile = Join-Path $root "src\AxCopilot\obj\project.assets.json" $configuration = "Release" $runtime = "win-x64" $targetFramework = "net8.0-windows10.0.17763.0" $output = Join-Path $root "src\AxCopilot\bin\$configuration\$targetFramework\$runtime" function Invoke-Dotnet { param( [Parameter(Mandatory = $true)] [string[]]$Arguments ) Write-Host ("dotnet " + ($Arguments -join " ")) -ForegroundColor DarkGray & dotnet @Arguments if ($LASTEXITCODE -ne 0) { throw "dotnet command failed with exit code $LASTEXITCODE." } } Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " AX Copilot - Quick Build (Windows)" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" if (-not (Test-Path $project)) { throw "Project file not found: $project" } if ($StopRunningApp) { $running = Get-Process -Name "AxCopilot" -ErrorAction SilentlyContinue if ($running) { Write-Host "[0/3] Stopping running AxCopilot.exe..." -ForegroundColor Yellow $running | Stop-Process -Force } } if ($Clean) { Write-Host "[1/3] Cleaning previous quick-build output..." -ForegroundColor Yellow Invoke-Dotnet -Arguments @( "clean", $project, "-c", $configuration, "-r", $runtime, "--nologo", "-v", "minimal" ) } $shouldRestore = $Restore -or -not (Test-Path $assetsFile) if ($shouldRestore) { Write-Host "[2/3] Restoring NuGet packages..." -ForegroundColor Yellow Invoke-Dotnet -Arguments @( "restore", $project, "-r", $runtime, "--nologo", "-v", "minimal" ) } Write-Host "[3/3] Building AxCopilot only (no installer, no publish)..." -ForegroundColor Yellow $buildArgs = @( "build", $project, "-c", $configuration, "-r", $runtime, "--nologo", "-v", "minimal", "-m", "-p:RunAnalyzersDuringBuild=false" ) if (-not $shouldRestore) { $buildArgs += "--no-restore" } Invoke-Dotnet -Arguments $buildArgs Write-Host "" Write-Host "========================================" -ForegroundColor Green Write-Host " Quick Build Complete" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host ("Output: " + $output) -ForegroundColor Green Write-Host "Skipped: installer, dist packaging, obfuscation, publish bundle" -ForegroundColor Green Write-Host "" Write-Host "Examples:" -ForegroundColor Cyan Write-Host " .\build-quick.ps1" Write-Host " .\build-quick.ps1 -StopRunningApp" Write-Host " .\build-quick.ps1 -Restore -Clean"