| 1 | # Publish Release (win-x64, self-contained) and mirror to a fixed path for Cursor MCP. |
| 2 | # Run from repo: cd ...\dotnet-build-test-mcp ; .\publish-and-deploy.ps1 |
| 3 | # Optional: -Target "D:\dotnet-build-test-mcp" |
| 4 | [CmdletBinding()] |
| 5 | param( |
| 6 | [string] $Target = "D:\dotnet-build-test-mcp" |
| 7 | ) |
| 8 | |
| 9 | $ErrorActionPreference = "Stop" |
| 10 | $here = $PSScriptRoot |
| 11 | $csproj = Join-Path $here "DotnetBuildTestMcp.csproj" |
| 12 | if (-not (Test-Path -LiteralPath $csproj)) { |
| 13 | Write-Error "DotnetBuildTestMcp.csproj not found. Run this script from the dotnet-build-test-mcp directory (PSScriptRoot=$here)." |
| 14 | exit 1 |
| 15 | } |
| 16 | |
| 17 | Push-Location $here |
| 18 | try { |
| 19 | # Keep docs/manifests in sync with ToolCatalog. |
| 20 | & dotnet run --project (Join-Path $here "tools\\ExportMcpManifest\\ExportMcpManifest.csproj") -- --write | Out-Null |
| 21 | if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 22 | |
| 23 | # Prefer local tool (repo-pinned), but global install works too. |
| 24 | if (Test-Path -LiteralPath (Join-Path $here ".config\\dotnet-tools.json")) { |
| 25 | & dotnet tool restore | Out-Null |
| 26 | & dotnet aid-publish -Project $csproj -Target $Target -Runtime "win-x64" -Configuration "Release" -SelfContained -KillRunning |
| 27 | } else { |
| 28 | & aid-publish -Project $csproj -Target $Target -Runtime "win-x64" -Configuration "Release" -SelfContained -KillRunning |
| 29 | } |
| 30 | if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 31 | |
| 32 | $exe = Join-Path $Target "DotnetBuildTestMcp.exe" |
| 33 | $exeJson = $exe.Replace('\', '\\') |
| 34 | Write-Host "" |
| 35 | Write-Host "Cursor MCP: paste into mcp.json ->" |
| 36 | Write-Host @" |
| 37 | "dotnet-build-test-mcp": { |
| 38 | "command": "$exeJson", |
| 39 | "args": [] |
| 40 | } |
| 41 | "@ |
| 42 | Write-Host "" |
| 43 | } finally { |
| 44 | Pop-Location |
| 45 | } |
| 46 | |
| 47 | |