| 1 | # Publish Release (self-contained win-x64) and mirror to a fixed path without spaces (for Cursor MCP). |
| 2 | # Run from repo root: cd ...\cascade-ide ; .\scripts\deploy\publish-release.ps1 |
| 3 | # Optional: -SkipDocGen (faster when IdeCommands XML-doc / MCP markdown codegen not changed) |
| 4 | # Optional: -Target "D:\cascade-ide" |
| 5 | [CmdletBinding()] |
| 6 | param( |
| 7 | [string] $Target = "D:\cascade-ide", |
| 8 | [switch] $SkipDocGen |
| 9 | ) |
| 10 | |
| 11 | $ErrorActionPreference = "Stop" |
| 12 | $repoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\..")) |
| 13 | $csproj = Join-Path $repoRoot "CascadeIDE.csproj" |
| 14 | if (-not (Test-Path -LiteralPath $csproj)) { |
| 15 | Write-Error "CascadeIDE.csproj not found. Run from cascade-ide repo (resolved root=$repoRoot)." |
| 16 | exit 1 |
| 17 | } |
| 18 | |
| 19 | $outDir = Join-Path $repoRoot "publish" |
| 20 | |
| 21 | $intercomPublish = Join-Path $repoRoot "scripts\intercom\publish-intercom-service.ps1" |
| 22 | $intercomOut = Join-Path $repoRoot "artifacts\intercom-service" |
| 23 | |
| 24 | Push-Location $repoRoot |
| 25 | try { |
| 26 | if (Test-Path -LiteralPath $intercomPublish) { |
| 27 | & pwsh -NoProfile -ExecutionPolicy Bypass -File $intercomPublish -Configuration Release -SelfContained -OutDir $intercomOut |
| 28 | if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 29 | } |
| 30 | |
| 31 | $publishArgs = @( |
| 32 | "publish", $csproj, |
| 33 | "-c", "Release", |
| 34 | "-r", "win-x64", |
| 35 | "--self-contained", "true", |
| 36 | "-o", $outDir, |
| 37 | "-v", "minimal" |
| 38 | ) |
| 39 | if ($SkipDocGen) { |
| 40 | $publishArgs += "/p:GenerateIdeProtocolDocs=false" |
| 41 | } |
| 42 | |
| 43 | & dotnet @publishArgs |
| 44 | if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 45 | |
| 46 | if (-not (Test-Path -LiteralPath $Target)) { |
| 47 | New-Item -ItemType Directory -Path $Target -Force | Out-Null |
| 48 | } |
| 49 | |
| 50 | robocopy $outDir $Target /E /MIR /NFL /NDL /NJH /NJS | Out-Null |
| 51 | $robocode = $LASTEXITCODE |
| 52 | if ($robocode -ge 8) { |
| 53 | Write-Error "robocopy failed with exit code $robocode" |
| 54 | exit $robocode |
| 55 | } |
| 56 | |
| 57 | if (Test-Path -LiteralPath $intercomOut) { |
| 58 | $intercomTarget = Join-Path $Target "tools\intercom-service" |
| 59 | New-Item -ItemType Directory -Path $intercomTarget -Force | Out-Null |
| 60 | robocopy $intercomOut $intercomTarget /E /MIR /NFL /NDL /NJH /NJS | Out-Null |
| 61 | $robocode = $LASTEXITCODE |
| 62 | if ($robocode -ge 8) { |
| 63 | Write-Error "robocopy intercom-service failed with exit code $robocode" |
| 64 | exit $robocode |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | $exe = Join-Path $Target "CascadeIDE.exe" |
| 69 | if (-not (Test-Path -LiteralPath $exe)) { |
| 70 | Write-Error "Expected exe not found: $exe" |
| 71 | exit 1 |
| 72 | } |
| 73 | |
| 74 | $ts = (Get-Item -LiteralPath $exe).LastWriteTimeUtc.ToString("o") |
| 75 | $exeJson = $exe.Replace('\', '\\') |
| 76 | Write-Host "" |
| 77 | Write-Host "OK: $exe (UTC $ts)" |
| 78 | Write-Host "" |
| 79 | Write-Host "Cursor MCP (Release): paste into mcp.json ->" |
| 80 | Write-Host @" |
| 81 | "cascade-ide": { |
| 82 | "command": "$exeJson", |
| 83 | "args": ["--mcp-stdio"] |
| 84 | } |
| 85 | "@ |
| 86 | Write-Host "" |
| 87 | } finally { |
| 88 | Pop-Location |
| 89 | } |
| 90 | |