agentleFS
VuDZVuDZ/RoslynMcpServer/.cursor/rules/roslyn-mcp-build-sdk.mdc

RoslynMcpServer / rules

Cursor rule8 starsChanged 46 days agoMITView on GitHub

SDK pinning, DotNet CLI, build/test parsers, MSBuild bitness

The file

We split this roslyn-mcp-build-sdk.mdc into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run metadata includes inherited overrides, strip/pin SDK env action, and SDK version inferred from MSBuild/NETSDK log paths.

    line 17
  2. Very specific:

    Default noIncremental=true → --no-incremental on every build step (agent verification must not trust MSBuild up-to-date).

    line 23

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
roslyn-mcp-build-sdk.mdc
---
description: SDK pinning, DotNet CLI, build/test parsers, MSBuild bitness
globs: Services/Build/DotNet*.cs,Services/Build/GlobalJson*.cs,Services/Workspace/Workspace*.cs,Diagnostics/**/*.cs,Tools/BuildTools.cs,Tools/TestTools.cs,Tools/RunTools.cs
alwaysApply: false
---

# Build / SDK / DotNet CLI

## Bitness

MCP process is 64-bit. x86 MSBuild/SDK → `BadImageFormatException`. Use 64-bit `dotnet` (`DotNetHostResolver`). `MsBuildBootstrapper.Register()` before workspace use.

## `global.json` pinning

`DotNetSdkEnvironment` / `GlobalJsonSdkReader`: pin via `MSBUILD_EXE_PATH`, `MSBuildSDKsPath`, `DOTNET_MSBUILD_SDK_RESOLVER_SDKS_*`, `DOTNET_ROOT`, inherit full process env. Working directory = nearest ancestor with `global.json` when possible.
Without a resolved pin, **strip** inherited `MSBuildSDKsPath` / `MSBUILD_EXE_PATH` / resolver vars (MSBuildLocator and Cursor/VS often leave SDK 9.x overrides → `NETSDK1045` on net10).
Run metadata includes inherited overrides, strip/pin **SDK env action**, and SDK version inferred from MSBuild/NETSDK log paths.

## `run_dotnet_build` (`DotNetBuildProbe`)

Escalate when diagnostics missing: `build -v:minimal` → `restore` → `build -v:normal`. Parse MSBuild `path(line,col): error|warning` **and** NuGet `NU####` / GHSA. Surface `MCP_MSBUILD_SDK_MISMATCH` if log SDK ≠ pin. Deduplicate repeated NU lines.
Optional tool arg `configuration` → `-c` on build steps only (multi-config `.slnx`: `Sit-Debug`, `Dit-Debug`, …). Omit to inherit `load_workspace` configuration. Optional `platform` → `-p:Platform=` (same inherit).
Default `noIncremental=true` → `--no-incremental` on every build step (agent verification must not trust MSBuild up-to-date). Effective exit = **last** `dotnet build` step — never let restore exit 0 mask a failed build with no rebuild. Report `Configuration` / `NoIncremental` in metadata.
While a step lives, `run_dotnet_build` emits MCP `notifications/progress` heartbeats (step label, elapsed, previous exit; no stdout) through `DotNetCliRunner`/`DotNetBuildProbe`; the SDK-injected `IProgress<ProgressNotificationValue>` parameter is schema-excluded (`McpToolHelpFormatter.IsMcpBoundParameter`). UX only — never claim it raises the host `tools/call` timeout.

## Tests (`VstestOutputParser` / `TestTools`)

Success often has `Test Run Successful` / `Total tests` + `Passed` **without** `Failed:` line — treat missing Failed/Skipped as 0. `.slnx` fail output often has `Total tests` + `Failed:` **without** `Passed:` — infer Passed = Total − Failed − Skipped. Avoid false `partial` status.
`run_specific_test` filter match: xUnit may print method-only names or Theory `FQN(args)` while the needle is `Ns.Class.Method`. Do not require a dotted FQN on the Passed line or `line.Contains(fullNeedle)`; match a display suffix with a `.` boundary. False **no matching tests** after `Passed: 1` sends agents into workspace/filter retries.
`run_dotnet_test` / `run_specific_test` / `run_test_by_filter`: `timeoutSeconds` (default 300, shared by pre-test build + test); optional `noBuild` / `noRestore`; optional `configuration` (`-c`) and `platform` (`-p:Platform=`), same as build (inherit from `load_workspace` when omitted). Failed-test Standard Output/Error are separate report blocks (default 2500/1000 chars head+tail; `includeFullOutput` / `maxOutputChars` raise the cap, safety 100000). Do not drop StdOut to protect the assertion. When `noBuild=false`, run incremental `dotnet build` then `dotnet test --no-build --no-restore` so `VstestOutputParser` never sees MSBuild warning dumps. Do not use `DotNetBuildProbe` for that compile. `noBuild=true` skips the extra build. Same MCP progress heartbeats as build (`dotnet build` / `dotnet test`; 5 s; no VSTest lines).

## Other

- `run_dotnet_run` — timeout, truncated stdout, stderr tail; MCP progress heartbeat (`dotnet run`, 5 s, no stdout) via `RunSeparatedAsync` + `CliProgressWatch`.
- `run_nuget_audit` — `dotnet list package --vulnerable`, structured table.
- `load_workspace` NuGet audit, prune/unused PackageReference, NU1701 TFM-compat, **and** design-time MSBuild advisories (ASPDEPR007 / IncludeOpenAPIAnalyzers, MSB3270, analyzer project without metadata) → warnings, not hard Failure; do not treat the word `failed` in the MSBuildWorkspace wrapper as fatal unless inner text has `error NU|MSB|NETSDK` or a known-hard pattern. Health block shows SDK/restore/tool count.
- Logs: summary + highlight lines; `ROSLYN_MCP_LOG_TOOL_OUTPUT=full` for verbose; `read_log_tail` / `tail_tool_log`.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.