Forge
powershellf583a481
1# Publish Release (win-x64, self-contained) and mirror to a fixed path for Cursor MCP.
2# Run from repo: cd ...\AIGuiders.SampleMcp ; .\publish-and-deploy.ps1
3# Optional: -Target "D:\sample-mcp"
4[CmdletBinding()]
5param(
6 [string] $Target = "D:\sample-mcp"
7)
8
9$ErrorActionPreference = "Stop"
10$here = $PSScriptRoot
11$csproj = Join-Path $here "AIGuiders.SampleMcp.csproj"
12if (-not (Test-Path -LiteralPath $csproj)) {
13 Write-Error "AIGuiders.SampleMcp.csproj not found. Run this script from the MCP directory (PSScriptRoot=$here)."
14 exit 1
15}
16
17Push-Location $here
18try {
19 $outDir = Join-Path $here "publish"
20 $publishArgs = @(
21 "publish", $csproj,
22 "-c", "Release",
23 "-r", "win-x64",
24 "-o", $outDir,
25 "-v", "minimal"
26 )
27
28 & dotnet @publishArgs
29 if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
30
31 if (-not (Test-Path -LiteralPath $Target)) {
32 New-Item -ItemType Directory -Path $Target -Force | Out-Null
33 }
34
35 robocopy $outDir $Target /E /MIR /NFL /NDL /NJH /NJS /R:2 /W:1 | Out-Null
36 $robocode = $LASTEXITCODE
37 if ($robocode -ge 8) {
38 Write-Error "robocopy failed with exit code $robocode"
39 exit $robocode
40 }
41
42 $exe = Join-Path $Target "AIGuiders.SampleMcp.exe"
43 if (-not (Test-Path -LiteralPath $exe)) {
44 Write-Error "Expected exe not found: $exe"
45 exit 1
46 }
47
48 $ts = (Get-Item -LiteralPath $exe).LastWriteTimeUtc.ToString("o")
49 $exeJson = $exe.Replace('\', '\\')
50 Write-Host ""
51 Write-Host "OK: $exe (UTC $ts)"
52 Write-Host ""
53 Write-Host "Cursor MCP: paste into mcp.json ->"
54 Write-Host @"
55 "sample-mcp": {
56 "command": "$exeJson",
57 "args": []
58 }
59"@
60 Write-Host ""
61} finally {
62 Pop-Location
63}
64
65
View only · write via MCP/CIDE