Forge
powershell551a3611
1# Publish Release (win-x64, self-contained) and mirror to a fixed path for Cursor MCP.
2# Run from repo: cd ...\roslyn-mcp ; .\publish-and-deploy.ps1
3# Optional: -Target "D:\roslyn-mcp"
4[CmdletBinding()]
5param(
6 [string] $Target = "D:\roslyn-mcp"
7)
8
9$ErrorActionPreference = "Stop"
10$here = $PSScriptRoot
11$csproj = Join-Path $here "RoslynMcp.csproj"
12if (-not (Test-Path -LiteralPath $csproj)) {
13 Write-Error "RoslynMcp.csproj not found. Run this script from the roslyn-mcp directory (PSScriptRoot=$here)."
14 exit 1
15}
16
17Push-Location $here
18try {
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 -RequireMirrorFile BuildHost-netcore/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll
28 } else {
29 & aid-publish -Project $csproj -Target $Target -Runtime "win-x64" -Configuration "Release" -SelfContained -KillRunning `
30 -RequireMirrorFile BuildHost-netcore/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll
31 }
32 if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
33
34 # Microsoft.CodeAnalysis.Workspaces.MSBuild 4.9+: out-of-process BuildHost must sit next to the exe.
35 # aid-publish mirrors the full publish tree — if BuildHost-netcore was ever missing here, MCP failed at roslyn_* with "build host could not be found".
36 $buildHostDll = Join-Path $Target "BuildHost-netcore\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll"
37 if (-not (Test-Path -LiteralPath $buildHostDll)) {
38 Write-Error "Publish incomplete: MSBuild Workspace BuildHost missing: $buildHostDll`nRun dotnet publish manually with -r win-x64 --self-contained true or fix SDK output.`nIf aid-publish is older than 0.1.2, dotnet tool restore and pin AIGuiders.DotnetTools.PublishFixedTarget 0.1.2+."
39 exit 1
40 }
41
42 $exe = Join-Path $Target "RoslynMcp.exe"
43 $exeJson = $exe.Replace('\', '\\')
44 Write-Host ""
45 Write-Host "Cursor MCP: paste into mcp.json ->"
46 Write-Host @"
47 "roslyn-mcp": {
48 "command": "$exeJson",
49 "args": []
50 }
51"@
52 Write-Host ""
53} finally {
54 Pop-Location
55}
56
57
View only · write via MCP/CIDE