From ec8ead80d76e6392e5d8ffc2aa96fa476067ef56 Mon Sep 17 00:00:00 2001 From: Jon Galloway Date: Sun, 1 Nov 2026 18:23:56 -0800 Subject: [PATCH 1/2] Support .NET 10 and .NET 11 RC3 in one tool package Build both targets with the pinned RC3 SDK, isolate SDK integration dependencies, and verify packaged tool selection and same-major roll-forward. Add compatibility CI and document the pending GA-only check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 14 +- .github/workflows/build.yml | 26 +- .github/workflows/codeql.yml | 1 + .github/workflows/copilot-setup-steps.yml | 1 + .github/workflows/publish-nuget.yml | 1 + .github/workflows/release-scenarios.yml | 1 + .github/workflows/tool-compatibility.yml | 132 +++++++++++ DotNetMcp.Tests/DotNetMcp.Tests.csproj | 11 +- .../Scenarios/McpScenarioClient.cs | 1 + .../Server/McpAppsMetaWireFormatTest.cs | 4 +- DotNetMcp.Tests/Server/McpConformanceTests.cs | 1 + DotNetMcp/DotNetMcp.csproj | 23 +- NuGet.Config | 7 + README.md | 56 ++++- doc/releasing.md | 2 +- doc/sdk-integration.md | 10 +- doc/telemetry.md | 2 +- doc/testing.md | 26 ++ global.json | 5 + scripts/test-tool-compatibility.ps1 | 224 ++++++++++++++++++ 20 files changed, 506 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/tool-compatibility.yml create mode 100644 NuGet.Config create mode 100644 scripts/test-tool-compatibility.ps1 diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 33c948c8..81345991 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -8,12 +8,14 @@ This project is an **MCP (Model Context Protocol) server** that integrates with ## Key Technologies -- **.NET 10.0**: The latest version of .NET (LTS - Long Term Support) +- **.NET 10.0 and .NET 11.0 RC3**: Dual-targeted server and tests; source builds use the exact RC3 SDK pinned in `global.json` - **Model Context Protocol SDK**: Version 2.0.0, with matching `ModelContextProtocol.Extensions.Tasks` - **Stdio Transport**: Communication via standard input/output - **Microsoft.Extensions.Hosting**: For application lifecycle management -- **Microsoft.TemplateEngine.\***: Direct integration with .NET Template Engine (v10.0.101) -- **Microsoft.Build.\***: MSBuild integration for framework validation (v18.0.2) +- **Microsoft.TemplateEngine.\***: v10.0.403 for `net10.0`, v11.0.100-rc.3.26522.148 for `net11.0`; keep dependency groups target-specific +- **Microsoft.Build.\***: MSBuild integration for framework validation (v18.9.6) + +`NuGet.Config` adds the public `dotnet-tools` feed for RC3's NuGet 8 dependencies. Packaged tools include those dependencies and do not require the feed at installation. Both targets expose the same MCP tools, and project defaults remain .NET 10 LTS. `RollForward=Minor` does not permit backward or cross-major runtime selection. Verify generated runtimeconfigs and packaged tool execution, not just project builds. ## Architecture @@ -96,7 +98,7 @@ dotnet build /path/to/dotnet-mcp/DotNetMcp/DotNetMcp.csproj ### Testing Changes After making code changes: -1. Build with full path: `dotnet build --project [full path to .csproj]` +1. Build both targets with full path: `dotnet build [full path to .csproj]` 2. Check for compilation errors 3. Test the MCP server manually if significant changes were made @@ -262,8 +264,8 @@ Framework validation and information. - 703 passing tests covering all 74 MCP tools - MCP conformance tests validate protocol compliance - See [doc/testing.md](../doc/testing.md) for details -- **Build the project**: `dotnet build --project [full path to .csproj]` -- **Run the server**: `dotnet run --project [full path to .csproj]` +- **Build the project**: `dotnet build [full path to .csproj]` +- **Run the server**: `dotnet run --framework net11.0 --project [full path to .csproj]` (or `net10.0`) - **Manual testing**: Test with MCP Inspector or Claude Desktop - Verify all commands work with various parameter combinations - **Test SDK integration**: Try the new template and framework info tools diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0511129d..934008a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,6 +86,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json - name: Restore dependencies run: dotnet restore DotNetMcp.slnx @@ -119,6 +120,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json - name: Restore dependencies run: dotnet restore DotNetMcp.slnx @@ -149,6 +151,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json - name: Restore dependencies run: dotnet restore DotNetMcp.slnx @@ -187,6 +190,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json - name: Display .NET info id: dotnet_info @@ -225,13 +229,17 @@ jobs: shell: bash run: | set -euo pipefail - coverage_file=$(find DotNetMcp.Tests/bin/Release -name '*.cobertura.xml' | head -n 1) - if [[ -z "${coverage_file}" ]]; then - echo "Error: No coverage file found matching '*.cobertura.xml' under 'DotNetMcp.Tests/bin/Release'." >&2 - exit 1 - fi - echo "Found coverage file: ${coverage_file}" - cp "${coverage_file}" coverage.cobertura.xml + mkdir -p coverage + for tfm in net10.0 net11.0; do + mapfile -t reports < <(find "DotNetMcp.Tests/bin/Release/$tfm" -name '*.cobertura.xml') + if [[ ${#reports[@]} -ne 1 ]]; then + echo "Expected exactly one Cobertura report for $tfm, found ${#reports[@]}." >&2 + exit 1 + fi + name="$tfm.cobertura.xml" + if [[ "$tfm" == "net10.0" ]]; then name="coverage.cobertura.xml"; fi + cp "${reports[0]}" "coverage/$name" + done - name: Upload coverage to Codecov id: upload_codecov @@ -239,7 +247,7 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # pin@v7 with: - files: coverage.cobertura.xml + files: coverage/coverage.cobertura.xml,coverage/net11.0.cobertura.xml token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: false @@ -248,7 +256,7 @@ jobs: uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7 with: name: coverage-cobertura - path: coverage.cobertura.xml + path: coverage/*.cobertura.xml - name: Run Performance Smoke Tests id: performance_smoke diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 506fb8ac..5d20ed80 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -85,6 +85,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json cache: true cache-dependency-path: | DotNetMcp.slnx diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index d1b2e773..6595fe3b 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -22,6 +22,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json - name: Restore dependencies run: dotnet restore DotNetMcp/DotNetMcp.csproj diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index b2303f26..d7f76fb6 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -46,6 +46,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json cache: true cache-dependency-path: "**/*.csproj" diff --git a/.github/workflows/release-scenarios.yml b/.github/workflows/release-scenarios.yml index fac3dbe7..a3645cf2 100644 --- a/.github/workflows/release-scenarios.yml +++ b/.github/workflows/release-scenarios.yml @@ -41,6 +41,7 @@ jobs: uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 with: dotnet-version: "10.0.x" + global-json-file: global.json - name: Display .NET info id: dotnet_info diff --git a/.github/workflows/tool-compatibility.yml b/.github/workflows/tool-compatibility.yml new file mode 100644 index 00000000..bb3cfacb --- /dev/null +++ b/.github/workflows/tool-compatibility.yml @@ -0,0 +1,132 @@ +name: Packaged Tool Compatibility + +on: + pull_request: + branches: [main] + push: + branches: [main] + workflow_dispatch: + inputs: + rc3_run_id: + description: "For GA-only verification: run ID containing an existing rc3-tool-package artifact (no rebuild)" + required: false + type: string + +permissions: + contents: read + actions: read + +jobs: + package: + if: ${{ !inputs.rc3_run_id }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin@v7.0.1 + with: + fetch-depth: 0 + - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0 + with: + global-json-file: global.json + dotnet-version: "10.0.x" + - name: Pack once with RC3 + run: dotnet pack "$GITHUB_WORKSPACE/DotNetMcp/DotNetMcp.csproj" --configuration Release --output artifacts/package + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7 + with: + name: rc3-tool-package + path: artifacts/package/*.nupkg + retention-days: 90 + + compatibility: + needs: package + if: ${{ always() && (needs.package.result == 'success' || (needs.package.result == 'skipped' && inputs.rc3_run_id)) }} + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + environment: ${{ inputs.rc3_run_id && fromJSON('["ga"]') || fromJSON('["net10", "rc3", "side-by-side"]') }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin@v7.0.1 + - name: Download current RC3 package + if: ${{ !inputs.rc3_run_id }} + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # pin@v8 + with: + name: rc3-tool-package + path: artifacts/package + - name: Download preserved RC3 package without rebuilding + if: ${{ inputs.rc3_run_id }} + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # pin@v8 + with: + name: rc3-tool-package + path: artifacts/package + run-id: ${{ inputs.rc3_run_id }} + github-token: ${{ github.token }} + - name: Install isolated SDKs (Linux) + if: runner.os != 'Windows' + shell: bash + env: + CASE: ${{ matrix.environment }} + run: | + set -euo pipefail + curl -fsSL https://dot.net/v1/dotnet-install.sh -o "$RUNNER_TEMP/dotnet-install.sh" + root="$RUNNER_TEMP/compatibility-dotnet" + if [[ "$CASE" == "net10" || "$CASE" == "side-by-side" ]]; then + bash "$RUNNER_TEMP/dotnet-install.sh" --channel 10.0 --quality ga --install-dir "$root" --no-path + fi + if [[ "$CASE" == "rc3" || "$CASE" == "side-by-side" ]]; then + bash "$RUNNER_TEMP/dotnet-install.sh" --version 11.0.100-rc.3.26522.148 --install-dir "$root" --no-path + fi + if [[ "$CASE" == "ga" ]]; then + bash "$RUNNER_TEMP/dotnet-install.sh" --channel 11.0 --quality ga --install-dir "$root" --no-path + fi + - name: Install isolated SDKs (Windows) + if: runner.os == 'Windows' + shell: pwsh + env: + CASE: ${{ matrix.environment }} + run: | + $ErrorActionPreference = 'Stop' + $installer = Join-Path $env:RUNNER_TEMP 'dotnet-install.ps1' + Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -OutFile $installer + $root = Join-Path $env:RUNNER_TEMP 'compatibility-dotnet' + if ($env:CASE -in @('net10', 'side-by-side')) { + & $installer -Channel 10.0 -Quality GA -InstallDir $root -NoPath + } + if ($env:CASE -in @('rc3', 'side-by-side')) { + & $installer -Version 11.0.100-rc.3.26522.148 -InstallDir $root -NoPath + } + if ($env:CASE -eq 'ga') { + & $installer -Channel 11.0 -Quality GA -InstallDir $root -NoPath + } + - name: Exercise packaged tool + shell: pwsh + env: + CASE: ${{ matrix.environment }} + run: | + $root = Join-Path $env:RUNNER_TEMP 'compatibility-dotnet' + $sdks = @(Get-ChildItem (Join-Path $root 'sdk') -Directory | Select-Object -ExpandProperty Name) + $major = if ($env:CASE -in @('net10', 'side-by-side')) { '10' } else { '11' } + $sdk = @($sdks | Where-Object { $_ -like "$major.*" }) + if ($sdk.Count -ne 1) { throw "Expected one .NET $major SDK: $sdks" } + $runtimeMajor = if ($env:CASE -eq 'net10') { '10' } else { '11' } + $runtime = @(Get-ChildItem (Join-Path $root 'shared/Microsoft.NETCore.App') -Directory | + Where-Object Name -Like "$runtimeMajor.*" | Select-Object -ExpandProperty Name) + if ($runtime.Count -ne 1) { throw 'Expected one server runtime for this case.' } + if ($env:CASE -eq 'ga' -and ($sdks -match '-' -or $runtime -match '-')) { + throw 'GA verification must not contain preview SDKs or runtimes.' + } + $packages = @(Get-ChildItem artifacts/package -Filter '*.nupkg') + if ($packages.Count -ne 1) { throw 'Expected exactly one preserved package.' } + ./scripts/test-tool-compatibility.ps1 -PackagePath $packages[0].FullName -DotnetRoot $root ` + -ExpectedFramework "net$runtimeMajor.0" -ProjectSdkVersion $sdk[0] ` + -ExpectedRuntimeVersion $runtime[0] -OutputDirectory (Join-Path $PWD 'artifacts/compatibility-results') + - name: Preserve selection evidence + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7 + with: + name: compatibility-${{ matrix.os }}-${{ matrix.environment }} + path: | + artifacts/compatibility-results/results.json + artifacts/compatibility-results/*.txt + if-no-files-found: warn diff --git a/DotNetMcp.Tests/DotNetMcp.Tests.csproj b/DotNetMcp.Tests/DotNetMcp.Tests.csproj index dfb9df6b..60a39c3a 100644 --- a/DotNetMcp.Tests/DotNetMcp.Tests.csproj +++ b/DotNetMcp.Tests/DotNetMcp.Tests.csproj @@ -1,7 +1,7 @@  - net10.0 + net10.0;net11.0 enable enable false @@ -10,7 +10,6 @@ - @@ -19,6 +18,14 @@ + + + + + + + + diff --git a/DotNetMcp.Tests/Scenarios/McpScenarioClient.cs b/DotNetMcp.Tests/Scenarios/McpScenarioClient.cs index 2028b704..c6505d1a 100644 --- a/DotNetMcp.Tests/Scenarios/McpScenarioClient.cs +++ b/DotNetMcp.Tests/Scenarios/McpScenarioClient.cs @@ -76,6 +76,7 @@ private async Task StartAsync(CancellationToken cancellationToken) _client = await McpClient.CreateAsync( transport, + new() { DiscoverProbeTimeout = TimeSpan.FromSeconds(30) }, loggerFactory: _loggerFactory, cancellationToken: cancellationToken); diff --git a/DotNetMcp.Tests/Server/McpAppsMetaWireFormatTest.cs b/DotNetMcp.Tests/Server/McpAppsMetaWireFormatTest.cs index 2d1933ba..e04a8a70 100644 --- a/DotNetMcp.Tests/Server/McpAppsMetaWireFormatTest.cs +++ b/DotNetMcp.Tests/Server/McpAppsMetaWireFormatTest.cs @@ -27,7 +27,9 @@ public async ValueTask InitializeAsync() }; _client = await McpClient.CreateAsync( - new StdioClientTransport(transportOptions)); + new StdioClientTransport(transportOptions), + new() { DiscoverProbeTimeout = TimeSpan.FromSeconds(30) }, + cancellationToken: TestContext.Current.CancellationToken); } public async ValueTask DisposeAsync() diff --git a/DotNetMcp.Tests/Server/McpConformanceTests.cs b/DotNetMcp.Tests/Server/McpConformanceTests.cs index 7f0213d1..83fc8cb7 100644 --- a/DotNetMcp.Tests/Server/McpConformanceTests.cs +++ b/DotNetMcp.Tests/Server/McpConformanceTests.cs @@ -63,6 +63,7 @@ public async ValueTask InitializeAsync() // Connect to the server and perform handshake _client = await McpClient.CreateAsync( new PerRequestLoggingTransport(transport), + new() { DiscoverProbeTimeout = TimeSpan.FromSeconds(30) }, loggerFactory: _loggerFactory, cancellationToken: TestContext.Current.CancellationToken); diff --git a/DotNetMcp/DotNetMcp.csproj b/DotNetMcp/DotNetMcp.csproj index d5716ee6..99d7e4ed 100644 --- a/DotNetMcp/DotNetMcp.csproj +++ b/DotNetMcp/DotNetMcp.csproj @@ -2,7 +2,8 @@ Exe - net10.0 + net10.0;net11.0 + Minor enable enable true @@ -50,11 +51,6 @@ - - - - - @@ -64,6 +60,21 @@ + + + + + + + + + + + + + + + diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 00000000..d699e3b3 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/README.md b/README.md index f2ccf0f3..9976a64c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Click to install in your preferred environment: [![VS Code Insiders - Install .NET MCP](https://img.shields.io/badge/VS_Code_Insiders-Install_.NET_MCP-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=dotnet-mcp&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22dnx%22%2C%22args%22%3A%5B%22Community.Mcp.DotNet%401.%2A%22%2C%22--yes%22%5D%7D&quality=insiders) [![Visual Studio - Install .NET MCP](https://img.shields.io/badge/Visual_Studio-Install_.NET_MCP-5C2D91?style=flat-square&logo=visualstudio&logoColor=white)](https://vs-open.link/mcp-install?%7B%22name%22%3A%22Community.Mcp.DotNet%22%2C%22type%22%3A%22stdio%22%2C%22command%22%3A%22dnx%22%2C%22args%22%3A%5B%22Community.Mcp.DotNet%401.%2A%22%2C%22--yes%22%5D%7D) -> **Note**: Quick install requires .NET 10 SDK. +> **Note**: Quick install requires the .NET 10 or .NET 11 SDK. Source builds require the pinned .NET 11 RC3 SDK. ## What is This? @@ -247,10 +247,36 @@ Use `dotnet_server_capabilities` to discover the negotiated protocol and feature ### Requirements -- **For Quick Install**: .NET 10 SDK -- **For Manual Install**: .NET 10 SDK +- **For package installation**: .NET 10 SDK or .NET 11 SDK (RC3 or later) +- **For source builds**: .NET SDK `11.0.100-rc.3.26522.148`, pinned in `global.json`; install the .NET 10 SDK alongside it to run both test targets - Visual Studio Code, Visual Studio 2022 (v17.13+), or Claude Desktop +### Runtime and SDK compatibility + +One package contains `net10.0` and `net11.0` builds with the same MCP tool surface. .NET 10-only machines remain supported. The .NET 11 build uses RC3 Template Engine and Hosting packages; this does not add new .NET 11-only tools or change the default .NET 10 LTS project recommendation. + +| Environment | Fresh installation with the selected SDK | Project support | +| --- | --- | --- | +| .NET 10 only | .NET 10 tool assets and runtime | .NET 10 projects | +| .NET 11 RC3 only | .NET 11 tool assets and RC3 runtime | .NET 11 projects | +| .NET 10 and 11 RC3 side by side, .NET 11 SDK selected | .NET 11 tool assets and runtime | .NET 10 projects with a project-local .NET 10 SDK pin, and .NET 11 projects | +| .NET 11 GA only | Intended to use the unchanged RC3-built .NET 11 assets | GA-only execution is pending verification | + +Tool asset selection follows the SDK used to install or launch the tool, not simply the highest runtime installed. A `global.json` can select an older SDK. Installing .NET 11 later does not retarget an existing .NET 10 tool installation; reinstall or update it using the desired SDK. For an explicit tool installation target, `dotnet tool install` also supports `--framework net11.0`. + +Both `dnx` and a tool-path install were exercised against the same package on isolated .NET 10, RC3, and side-by-side installations. Neither required `--allow-roll-forward`. For a specific package version, use: + +```text +dnx Community.Mcp.DotNet@ --yes +dotnet tool install Community.Mcp.DotNet@ --tool-path ./tools +``` + +Replace `` with the desired published version. An exact prerelease version does not require `--prerelease`; floating prerelease selection does. Point MCP clients at the installed `dotnet-mcp` executable when using a tool-path install. + +The package explicitly uses `RollForward=Minor`, keeping runtime resolution within the target major version. Its .NET 11 runtime floor is `11.0.0-rc.3.26522.148`. RC3-to-GA is a same-major runtime transition, not a reason to require `Major` roll-forward. This policy is configured and the RC3 package is retained for GA testing, but **GA compatibility is not yet verified**. A .NET 11-only build cannot run backward on .NET 10; the separate .NET 10 assets provide that support. + +The server runtime and the SDK used for project commands are separate choices. Future SDK-specific CLI features should be checked against the selected project's SDK; only features using .NET 11-only in-process APIs need the .NET 11 server build. + ### Option 1: Quick Install (Recommended) Use the install badges at the top of this page to automatically configure the MCP server in your environment. The server will be downloaded from NuGet.org on first use. @@ -276,7 +302,7 @@ Edit your VS Code settings (`Ctrl+,` or `Cmd+,`, search for "mcp"): "dotnet": { "type": "stdio", "command": "dotnet", - "args": ["run", "--project", "/path/to/dotnet-mcp/DotNetMcp/DotNetMcp.csproj"] + "args": ["run", "--framework", "net11.0", "--project", "/path/to/dotnet-mcp/DotNetMcp/DotNetMcp.csproj"] } } } @@ -301,7 +327,7 @@ Edit your VS Code settings (`Ctrl+,` or `Cmd+,`, search for "mcp"): - **Name**: `dotnet` - **Type**: `stdio` - **Command**: `dotnet` - - **Arguments**: `run --project C:\path\to\dotnet-mcp\DotNetMcp\DotNetMcp.csproj` + - **Arguments**: `run --framework net11.0 --project C:\path\to\dotnet-mcp\DotNetMcp\DotNetMcp.csproj` 📖 [Full Visual Studio MCP documentation](https://learn.microsoft.com/en-us/visualstudio/ide/mcp-servers?view=vs-2022) @@ -344,7 +370,7 @@ Edit your VS Code settings (`Ctrl+,` or `Cmd+,`, search for "mcp"): "mcpServers": { "dotnet": { "command": "dotnet", - "args": ["run", "--project", "/path/to/dotnet-mcp/DotNetMcp/DotNetMcp.csproj"] + "args": ["run", "--framework", "net11.0", "--project", "/path/to/dotnet-mcp/DotNetMcp/DotNetMcp.csproj"] } } } @@ -357,7 +383,7 @@ Edit your VS Code settings (`Ctrl+,` or `Cmd+,`, search for "mcp"): "mcpServers": { "dotnet": { "command": "dotnet", - "args": ["run", "--project", "C:\\path\\to\\dotnet-mcp\\DotNetMcp\\DotNetMcp.csproj"] + "args": ["run", "--framework", "net11.0", "--project", "C:\\path\\to\\dotnet-mcp\\DotNetMcp\\DotNetMcp.csproj"] } } } @@ -1062,18 +1088,22 @@ await callTool("dotnet_dev_certs", { For development or contributing: +Install the exact RC3 SDK pinned in `global.json`. The repository's `NuGet.Config` adds Microsoft's public `dotnet-tools` feed because Template Engine RC3 depends on NuGet `8.0.0-rc.2448` packages that are not yet on NuGet.org. Retain your normal NuGet.org source for the other dependencies; this extra feed is needed to build, not to install the tool's bundled dependencies. The tool still requires a compatible .NET runtime. + ```bash git clone https://github.com/jongalloway/dotnet-mcp.git cd dotnet-mcp -dotnet build --project DotNetMcp/DotNetMcp.csproj +dotnet build "$PWD/DotNetMcp/DotNetMcp.csproj" ``` **Run the server**: ```bash -dotnet run --project DotNetMcp/DotNetMcp.csproj +dotnet run --framework net11.0 --project DotNetMcp/DotNetMcp.csproj ``` +Choose `--framework net10.0` instead to run the .NET 10 build. `dotnet run` requires an explicit framework for this multi-targeted project. Package consumers do not need the RC3 build SDK to run the .NET 10 assets. + The server communicates via stdio transport and is designed to be invoked by MCP clients. ## Project Structure @@ -1113,11 +1143,11 @@ Key files to start with: - **Protocol**: [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) - **SDK**: [MCP SDK for .NET](https://github.com/modelcontextprotocol/csharp-sdk) v2.3.0, with matching Tasks and Apps extensions -- **Runtime**: .NET 10.0 (target framework) +- **Runtime**: .NET 10.0 and .NET 11.0 RC3 (dual-targeted tool) - **Transport**: stdio (standard input/output) - **NuGet Packages**: - - `Microsoft.TemplateEngine.Abstractions` & `Edge` (v10.0.403) - Template metadata - - `Microsoft.Build.Utilities.Core` (v18.11.0) & `Microsoft.Build` (v18.9.6) - Project validation + - `Microsoft.TemplateEngine.Abstractions` & `Edge` (v10.0.403 for .NET 10; v11.0.100-rc.3.26522.148 for .NET 11) - Template metadata + - `Microsoft.Build.Utilities.Core` & `Microsoft.Build` (v18.9.6) - Project validation ## Documentation @@ -1207,7 +1237,7 @@ See [.github/copilot-instructions.md](.github/copilot-instructions.md) for devel ### "dnx not found" - **Cause**: .NET 10 SDK not installed -- **Solution**: Install [.NET 10 SDK](https://dotnet.microsoft.com/download) or use manual configuration with `dotnet run` +- **Solution**: Install the [.NET 10 or .NET 11 SDK](https://dotnet.microsoft.com/download). Source-based manual configuration additionally requires the pinned RC3 SDK and an explicit `--framework`. ### "No templates found" diff --git a/doc/releasing.md b/doc/releasing.md index b65702fa..4af2275c 100644 --- a/doc/releasing.md +++ b/doc/releasing.md @@ -65,7 +65,7 @@ If you do want a long-running, in-repo history, use [CHANGELOG.md](../CHANGELOG. Optional but recommended: -- `dotnet build --project DotNetMcp/DotNetMcp.csproj` +- `dotnet build "$PWD/DotNetMcp/DotNetMcp.csproj"` (uses the pinned RC3 SDK and builds both targets) - `dotnet test --solution DotNetMcp.slnx` ### 2) Create an annotated tag diff --git a/doc/sdk-integration.md b/doc/sdk-integration.md index 02c0a3b1..3556766e 100644 --- a/doc/sdk-integration.md +++ b/doc/sdk-integration.md @@ -36,8 +36,12 @@ See [SDK compatibility](sdk-v1.1-compatibility.md) for confirmation, deprecated ### Template Engine -- **Microsoft.TemplateEngine.Abstractions** (v10.0.403) -- **Microsoft.TemplateEngine.Edge** (v10.0.403) +- **Microsoft.TemplateEngine.Abstractions** (v10.0.403 on `net10.0`; v11.0.100-rc.3.26522.148 on `net11.0`) +- **Microsoft.TemplateEngine.Edge** (same target-specific versions) + +The server and tests target both frameworks. Hosting follows the same split: 10.0.14 on .NET 10 and 11.0.0-rc.3.26522.148 on .NET 11. The .NET 11 dependency graph uses NuGet 8.0.0-rc.2448; the direct .NET 10 NuGet.Frameworks reference remains 7.9.0. `NuGet.Config` adds Microsoft's public `dotnet-tools` feed for the RC3 NuGet dependencies that are not yet available on NuGet.org. The packed tool includes its dependencies, so consumer installs do not need that feed. + +Both builds expose the same tool surface. Framework recommendations remain .NET 10 LTS. The server runtime does not determine the SDK used for project CLI commands: a project-local `global.json` can select .NET 10 while the server runs on .NET 11. Provides programmatic access to the .NET template system: @@ -48,7 +52,7 @@ Provides programmatic access to the .NET template system: ### MSBuild -- **Microsoft.Build.Utilities.Core** (v18.11.0) +- **Microsoft.Build.Utilities.Core** (v18.9.6) - **Microsoft.Build** (v18.9.6) Provides framework validation, metadata, and project analysis: diff --git a/doc/telemetry.md b/doc/telemetry.md index 4f0b4d73..e99ed2df 100644 --- a/doc/telemetry.md +++ b/doc/telemetry.md @@ -167,7 +167,7 @@ builder.Services.AddOpenTelemetry() .AddOtlpExporter()); ``` -Keep the existing server registrations and stderr console logging. Run the customized server with `dotnet run --project DotNetMcp\DotNetMcp.csproj` through an MCP client. Once the provider/exporter has been added, standard OpenTelemetry settings such as `OTEL_EXPORTER_OTLP_ENDPOINT` configure the collector connection. Choose a sampler appropriate for your deployment. +Keep the existing server registrations and stderr console logging. Run the customized server with `dotnet run --framework net11.0 --project DotNetMcp\DotNetMcp.csproj` through an MCP client (or select `net10.0`). Once the provider/exporter has been added, standard OpenTelemetry settings such as `OTEL_EXPORTER_OTLP_ENDPOINT` configure the collector connection. Choose a sampler appropriate for your deployment. **Do not send telemetry to stdout.** The default OpenTelemetry console exporter writes there and can corrupt the stdio JSON-RPC stream. Use OTLP export to an explicitly configured collector; any console diagnostics must go to stderr. diff --git a/doc/testing.md b/doc/testing.md index 925318dc..6fae7463 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -30,6 +30,8 @@ This project uses **consolidated tools** as the primary test surface: ## Quick start +Install the exact .NET 11 RC3 SDK pinned in `global.json` and the .NET 10 SDK/runtime. The server and tests target both `net10.0` and `net11.0`; the commands below run both targets unless `--framework` selects one. Stdio tests discover the server binary for their own framework. Discovery probes allow for cold startup when both suites run concurrently. + Run all tests (recommended): ```bash @@ -320,6 +322,30 @@ dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -- --cov The Cobertura XML will be written under the test output folder, typically: - `DotNetMcp.Tests/bin/Release/net10.0/TestResults/*.cobertura.xml` +- `DotNetMcp.Tests/bin/Release/net11.0/TestResults/*.cobertura.xml` + +CI uploads both reports and submits both to Codecov. The .NET 10 report retains the artifact filename `coverage.cobertura.xml` for the existing download/diagnostic script; the additional report is `net11.0.cobertura.xml`. + +## Packaged-tool compatibility + +The `Packaged Tool Compatibility` workflow builds one dual-targeted package with the pinned RC3 SDK. On Windows and Linux it tests that package using `dnx` and a fresh tool-path install in isolated .NET 10-only, RC3-only, and side-by-side SDK roots. Tests initialize MCP, list tools and templates, create/analyze/build a console project, and inspect host traces to assert the selected tool assets and loaded runtime. The side-by-side case runs the .NET 11 tool against a project pinned to the .NET 10 SDK. + +To run a case locally, supply a complete isolated SDK installation (not just a runtime), the exact SDK/runtime versions, and a new output directory: + +```powershell +dotnet pack "$PWD\DotNetMcp\DotNetMcp.csproj" -c Release -o artifacts/package +pwsh -File scripts/test-tool-compatibility.ps1 ` + -PackagePath artifacts/package/Community.Mcp.DotNet..nupkg ` + -DotnetRoot C:\isolated-sdk-rc3 ` + -ExpectedFramework net11.0 ` + -ProjectSdkVersion 11.0.100-rc.3.26522.148 ` + -ExpectedRuntimeVersion 11.0.0-rc.3.26522.148 ` + -OutputDirectory artifacts/compatibility-rc3 +``` + +Use the official `dotnet-install` script to provision each isolated root without modifying system installations. For the side-by-side case install both SDKs into one root and pass the .NET 10 project SDK version with `-ExpectedFramework net11.0`. The harness pins tool installation to the SDK matching `ExpectedFramework`, independently of the project SDK. It sets isolated CLI homes, package caches, tool paths, and host roots; inherited runtime roll-forward overrides are removed. Neither invocation uses `--allow-roll-forward`. + +The workflow preserves `rc3-tool-package` for 90 days. Download and retain that artifact before expiry if needed. **GA-only verification remains pending until .NET 11 GA is available.** To exercise GA later, dispatch the workflow with `rc3_run_id` pointing to an earlier run containing that artifact. The package job is skipped; the existing package is downloaded and run in a GA-only root without rebuilding or installing RC3. Compare the SHA-256 recorded in each `results.json` to confirm artifact identity. Failure to obtain GA or the preserved artifact fails the check; it is not counted as a pass. ## Downloading CI coverage artifacts diff --git a/global.json b/global.json index 9009caf0..0a04fd69 100644 --- a/global.json +++ b/global.json @@ -1,4 +1,9 @@ { + "sdk": { + "version": "11.0.100-rc.3.26522.148", + "rollForward": "disable", + "allowPrerelease": true + }, "test": { "runner": "Microsoft.Testing.Platform" } diff --git a/scripts/test-tool-compatibility.ps1 b/scripts/test-tool-compatibility.ps1 new file mode 100644 index 00000000..cd016ecd --- /dev/null +++ b/scripts/test-tool-compatibility.ps1 @@ -0,0 +1,224 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory)] + [string] $PackagePath, + [Parameter(Mandatory)] + [string] $DotnetRoot, + [Parameter(Mandatory)] + [ValidateSet('net10.0', 'net11.0')] + [string] $ExpectedFramework, + [Parameter(Mandatory)] + [string] $ProjectSdkVersion, + [Parameter(Mandatory)] + [string] $ExpectedRuntimeVersion, + [string] $OutputDirectory = (Join-Path ([System.IO.Path]::GetTempPath()) "dotnet-mcp-compatibility-$([guid]::NewGuid().ToString('N'))"), + [ValidateRange(1, 600)] + [int] $TimeoutSeconds = 120 +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version Latest + +$PackagePath = (Resolve-Path -LiteralPath $PackagePath).Path +$DotnetRoot = (Resolve-Path -LiteralPath $DotnetRoot).Path +if (Test-Path -LiteralPath $OutputDirectory) { + throw "OutputDirectory must be new so tool caches cannot affect selection: $OutputDirectory" +} +$OutputDirectory = [System.IO.Directory]::CreateDirectory($OutputDirectory).FullName +$dotnet = Join-Path $DotnetRoot $(if ($IsWindows) { 'dotnet.exe' } else { 'dotnet' }) +if (-not (Test-Path -LiteralPath $dotnet)) { throw "dotnet host not found: $dotnet" } + +$archive = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) +try { + $nuspec = @($archive.Entries | Where-Object FullName -Like '*.nuspec') + if ($nuspec.Count -ne 1) { throw 'Expected exactly one package manifest.' } + $reader = [System.IO.StreamReader]::new($nuspec[0].Open()) + try { [xml] $manifest = $reader.ReadToEnd() } finally { $reader.Dispose() } + $packageId = $manifest.package.metadata.id + $version = $manifest.package.metadata.version + if ($packageId -ne 'Community.Mcp.DotNet') { throw "Unexpected package: $packageId" } + foreach ($tfm in @('net10.0', 'net11.0')) { + $entry = $archive.GetEntry("tools/$tfm/any/DotNetMcp.runtimeconfig.json") + if ($null -eq $entry) { throw "Package is missing $tfm runtimeconfig." } + $reader = [System.IO.StreamReader]::new($entry.Open()) + try { $options = ($reader.ReadToEnd() | ConvertFrom-Json).runtimeOptions } finally { $reader.Dispose() } + if ($options.tfm -ne $tfm -or $options.rollForward -ne 'Minor') { + throw "Unexpected runtime contract for ${tfm}: $($options | ConvertTo-Json -Compress)" + } + $expectedFloor = if ($tfm -eq 'net10.0') { '10.0.0' } else { '11.0.0-rc.3.26522.148' } + if ($options.framework.version -ne $expectedFloor) { throw "Unexpected runtime floor for $tfm" } + if ($null -eq $archive.GetEntry("tools/$tfm/any/DotnetToolSettings.xml")) { + throw "Package is missing $tfm tool settings." + } + } +} +finally { $archive.Dispose() } + +$environment = @{ + DOTNET_ROOT = $DotnetRoot + DOTNET_ROOT_X64 = $DotnetRoot + DOTNET_ROOT_ARM64 = $DotnetRoot + DOTNET_HOST_PATH = $dotnet + DOTNET_MULTILEVEL_LOOKUP = '0' + DOTNET_CLI_HOME = (Join-Path $OutputDirectory 'home') + DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' + DOTNET_CLI_TELEMETRY_OPTOUT = '1' + DOTNET_NOLOGO = '1' + NUGET_PACKAGES = (Join-Path $OutputDirectory 'packages') + NUGET_HTTP_CACHE_PATH = (Join-Path $OutputDirectory 'http-cache') + PATH = "$DotnetRoot$([System.IO.Path]::PathSeparator)$env:PATH" +} +$work = [System.IO.Directory]::CreateDirectory((Join-Path $OutputDirectory 'work')).FullName +$feed = [System.IO.Directory]::CreateDirectory((Join-Path $OutputDirectory 'feed')).FullName +Copy-Item -LiteralPath $PackagePath -Destination $feed +# Consumer tests deliberately override the checkout's RC3 SDK pin and package sources. +$toolMajor = $ExpectedFramework.Substring(3).Split('.')[0] +$toolSdks = @(Get-ChildItem (Join-Path $DotnetRoot 'sdk') -Directory | Where-Object Name -Like "$toolMajor.*") +if ($toolSdks.Count -ne 1) { throw "Expected one .NET $toolMajor SDK in the isolated root." } +@{ sdk = @{ version = $toolSdks[0].Name; rollForward = 'disable'; allowPrerelease = $true } } | + ConvertTo-Json -Depth 4 | Set-Content -LiteralPath (Join-Path $work 'global.json') +$projectRoot = [System.IO.Directory]::CreateDirectory((Join-Path $work 'projects')).FullName +@{ sdk = @{ version = $ProjectSdkVersion; rollForward = 'disable'; allowPrerelease = $true } } | + ConvertTo-Json -Depth 4 | Set-Content -LiteralPath (Join-Path $projectRoot 'global.json') +$config = Join-Path $work 'NuGet.Config' +'' | Set-Content -LiteralPath $config + +function New-ChildProcess([string] $FilePath, [string[]] $Arguments, [string] $TraceFile = '') { + $info = [System.Diagnostics.ProcessStartInfo]::new() + $info.FileName = $FilePath + $info.WorkingDirectory = $work + $info.UseShellExecute = $false + $info.RedirectStandardInput = $true + $info.RedirectStandardOutput = $true + $info.RedirectStandardError = $true + foreach ($argument in $Arguments) { $info.ArgumentList.Add($argument) } + foreach ($key in $environment.Keys) { $info.Environment[$key] = $environment[$key] } + foreach ($key in @('DOTNET_ROLL_FORWARD', 'DOTNET_ROLL_FORWARD_TO_PRERELEASE', 'DOTNET_ADDITIONAL_DEPS', + 'DOTNET_SHARED_STORE', 'DOTNET_STARTUP_HOOKS', 'MSBuildSDKsPath', 'DOTNET_HOST_TRACEFILE', 'COREHOST_TRACEFILE')) { + $null = $info.Environment.Remove($key) + } + $info.Environment['DOTNET_HOST_TRACE'] = $(if ($TraceFile) { '1' } else { '0' }) + $info.Environment['COREHOST_TRACE'] = '0' + if ($TraceFile) { $info.Environment['DOTNET_HOST_TRACEFILE'] = $TraceFile } + $process = [System.Diagnostics.Process]::new() + $process.StartInfo = $info + if (-not $process.Start()) { throw "Could not start $FilePath" } + return $process +} + +function Invoke-Checked([string[]] $Arguments) { + $process = New-ChildProcess $dotnet $Arguments + try { + $stdout = $process.StandardOutput.ReadToEndAsync() + $stderr = $process.StandardError.ReadToEndAsync() + if (-not $process.WaitForExit($TimeoutSeconds * 1000)) { throw "Timed out: dotnet $Arguments" } + $text = $stdout.GetAwaiter().GetResult() + $stderr.GetAwaiter().GetResult() + if ($process.ExitCode -ne 0) { throw "dotnet $Arguments failed ($($process.ExitCode)):`n$text" } + return $text + } + finally { + if (-not $process.HasExited) { $process.Kill($true); $process.WaitForExit() } + $process.Dispose() + } +} + +function Invoke-Rpc($Process, [int] $Id, [string] $Method, [hashtable] $Parameters) { + $message = @{ jsonrpc = '2.0'; id = $Id; method = $Method; params = $Parameters } | ConvertTo-Json -Depth 20 -Compress + $Process.StandardInput.WriteLine($message) + $deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSeconds) + do { + $read = $Process.StandardOutput.ReadLineAsync() + $remaining = [int] [Math]::Max(1, ($deadline - [DateTime]::UtcNow).TotalMilliseconds) + if (-not $read.Wait($remaining)) { throw "Timed out waiting for $Method" } + $line = $read.GetAwaiter().GetResult() + if ($null -eq $line) { throw "Server exited before responding to $Method" } + $response = $line | ConvertFrom-Json -AsHashtable + if ($response.ContainsKey('id') -and $response.id -eq $Id) { + if ($response.ContainsKey('error')) { throw "$Method failed: $($response.error | ConvertTo-Json -Compress)" } + return $response.result + } + if ([DateTime]::UtcNow -ge $deadline) { throw "Timed out waiting for $Method" } + } while ($true) +} + +function Invoke-Tool($Process, [int] $Id, [string] $Name, [hashtable] $Arguments) { + $result = Invoke-Rpc $Process $Id 'tools/call' @{ name = $Name; arguments = $Arguments } + $text = ($result.content | Where-Object type -EQ 'text' | ForEach-Object text) -join "`n" + if (($result.ContainsKey('isError') -and $result.isError -eq $true) -or $text -match 'Exit Code: [1-9]|^Error:') { + throw "${Name} failed: $text" + } + return $text +} + +$sdkList = Invoke-Checked @('--list-sdks') +$runtimeList = Invoke-Checked @('--list-runtimes') +if ($runtimeList -notmatch [regex]::Escape("Microsoft.NETCore.App $ExpectedRuntimeVersion ")) { + throw "Expected runtime is not installed in the isolated root: $ExpectedRuntimeVersion" +} +$projectFramework = 'net' + $ProjectSdkVersion.Split('.')[0] + '.0' +$results = @() +foreach ($invocation in @('tool', 'dnx')) { + $trace = Join-Path $OutputDirectory "$invocation-host.txt" + if ($invocation -eq 'tool') { + $toolPath = Join-Path $OutputDirectory 'tools' + $installOutput = Invoke-Checked @('tool', 'install', "$packageId@$version", '--tool-path', $toolPath, + '--configfile', $config, '--add-source', $feed, '--verbosity', 'quiet') + $installOutput | Set-Content -LiteralPath (Join-Path $OutputDirectory 'install.txt') + $command = Join-Path $toolPath $(if ($IsWindows) { 'dotnet-mcp.exe' } else { 'dotnet-mcp' }) + $arguments = @() + } + else { + $command = $dotnet + $arguments = @('dnx', "$packageId@$version", '--yes', '--configfile', $config, '--add-source', $feed) + } + $process = New-ChildProcess $command $arguments $trace + $stderr = $process.StandardError.ReadToEndAsync() + try { + $null = Invoke-Rpc $process 1 'initialize' @{ + protocolVersion = '2025-11-25' + capabilities = @{} + clientInfo = @{ name = 'package-compatibility'; version = '1.0' } + } + $process.StandardInput.WriteLine('{"jsonrpc":"2.0","method":"notifications/initialized"}') + $tools = Invoke-Rpc $process 2 'tools/list' @{} + foreach ($name in @('dotnet_sdk', 'dotnet_project')) { + if ($name -notin $tools.tools.name) { throw "Missing MCP tool: $name" } + } + $templates = Invoke-Tool $process 3 'dotnet_sdk' @{ action = 'ListTemplates' } + if ($templates -notmatch 'console') { throw "Console template was not discovered: $templates" } + $projectDir = Join-Path $projectRoot "sample-$invocation" + $null = Invoke-Tool $process 4 'dotnet_project' @{ + action = 'New'; template = 'console'; name = 'CompatibilitySample' + output = $projectDir; framework = $projectFramework; workingDirectory = $projectRoot + } + $project = Join-Path $projectDir 'CompatibilitySample.csproj' + $analysis = Invoke-Tool $process 5 'dotnet_project' @{ action = 'Analyze'; projectPath = $project } + if ($analysis -notmatch [regex]::Escape($projectFramework)) { throw "Missing framework in project analysis: $analysis" } + $build = Invoke-Tool $process 6 'dotnet_project' @{ action = 'Build'; project = $project; workingDirectory = $projectRoot } + if ($build -notmatch '"success"\s*:\s*true') { throw "Project build did not report success: $build" } + } + finally { + try { + $process.StandardInput.Close() + if (-not $process.WaitForExit(10000)) { $process.Kill($true); $process.WaitForExit() } + $stderr.GetAwaiter().GetResult() | Set-Content -LiteralPath (Join-Path $OutputDirectory "$invocation-stderr.txt") + } + finally { $process.Dispose() } + } + $hostTrace = Get-Content -LiteralPath $trace -Raw + $assetPattern = 'tools[/\\]' + [regex]::Escape($ExpectedFramework) + '[/\\]any[/\\]DotNetMcp.dll' + if ($hostTrace -notmatch $assetPattern) { throw "Host did not select $ExpectedFramework assets; see $trace" } + $runtimePattern = [regex]::Escape([System.IO.Path]::Join( + $DotnetRoot, 'shared', 'Microsoft.NETCore.App', $ExpectedRuntimeVersion, 'System.Private.CoreLib.dll')) + if ($hostTrace -notmatch $runtimePattern) { throw "Host did not load expected runtime; see $trace" } + $results += @{ + invocation = $invocation; framework = $ExpectedFramework; runtime = $ExpectedRuntimeVersion + projectFramework = $projectFramework; allowRollForward = $false; passed = $true + } +} +@{ + package = [System.IO.Path]::GetFileName($PackagePath) + sha256 = (Get-FileHash -LiteralPath $PackagePath -Algorithm SHA256).Hash + sdkInventory = $sdkList; runtimeInventory = $runtimeList; results = $results +} | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $OutputDirectory 'results.json') +Write-Host "Packaged tool compatibility passed. Results: $OutputDirectory" From 569741394c4211ea301ebfc87aca0cec59204c80 Mon Sep 17 00:00:00 2001 From: Jon Galloway Date: Sun, 1 Nov 2026 19:31:44 -0800 Subject: [PATCH 2/2] Use solution discovery for RC3 repository test runs Keep existing test selectors, coverage options and both target frameworks while avoiding the pinned SDK's project-discovery regression. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 5 ++- .github/workflows/build.yml | 14 ++++----- .github/workflows/release-scenarios.yml | 4 +-- doc/performance-baseline.md | 4 +-- doc/testing.md | 39 +++++++++++------------- scripts/run-release-gate-tests.ps1 | 2 +- scripts/validate-coverage-exclusions.ps1 | 2 +- 7 files changed, 32 insertions(+), 38 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 81345991..ba6413ae 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -104,9 +104,8 @@ After making code changes: When running tests: -- Use `dotnet test --project ...` to run a specific test project. - - Do not pass a `.csproj` as a positional argument; `dotnet test` will warn: `Specifying a project for 'dotnet test' should be via '--project'`. -- Use `dotnet test --solution ...` to run from the solution. +- Run this repository's tests with `dotnet test --solution DotNetMcp.slnx`. The pinned .NET 11 RC3 SDK has a `--project` discovery regression; solution discovery runs both target frameworks without changing test selectors. +- For other projects, MTP supports `--project ...`; do not pass a `.csproj` as a positional argument. - Use Microsoft Testing Platform filters after `--` (for example `--filter-class ...`). ## SDK Integration Patterns diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 934008a3..7ddbec3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: run: pwsh -File scripts/validate-server-json.ps1 - name: Run MCP Conformance and Project Analysis Tests - run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" --filter-class "*ProjectAnalysisHelperTests" + run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" --filter-class "*ProjectAnalysisHelperTests" pr_scenario: # Runs only when scenario-specific files (Scenarios/Prompts/Resources) change. @@ -131,7 +131,7 @@ jobs: - name: Run MCP Scenario Tests env: DOTNET_MCP_SCENARIO_TESTS: "1" - run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" + run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" manual_quick_checks: if: ${{ github.event_name == 'workflow_dispatch' && inputs.runFullValidation != 'true' }} @@ -163,13 +163,13 @@ jobs: run: pwsh -File scripts/validate-server-json.ps1 - name: Run MCP Conformance Tests - run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" + run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" - name: Run MCP Scenario Tests if: ${{ inputs.runScenarioTests == 'true' }} env: DOTNET_MCP_SCENARIO_TESTS: "1" - run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" + run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" full_validation: if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.runFullValidation == 'true') }} @@ -210,7 +210,7 @@ jobs: - name: Run MCP Conformance Tests id: conformance_tests - run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" + run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" - name: Run MCP Scenario Tests id: scenario_tests @@ -218,7 +218,7 @@ jobs: if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.runScenarioTests == 'true') }} env: DOTNET_MCP_SCENARIO_TESTS: "1" - run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" + run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" - name: Test id: test @@ -267,7 +267,7 @@ jobs: run: | set -uo pipefail echo "Running performance smoke tests..." - dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj \ + dotnet test --solution DotNetMcp.slnx \ --no-build --configuration Release \ --verbosity detailed \ -- --filter-namespace "*Performance*" > performance-results.txt 2>&1 || true diff --git a/.github/workflows/release-scenarios.yml b/.github/workflows/release-scenarios.yml index a3645cf2..778bdd8f 100644 --- a/.github/workflows/release-scenarios.yml +++ b/.github/workflows/release-scenarios.yml @@ -62,8 +62,8 @@ jobs: - name: Run Scenario + Release Scenario Tests id: release_scenarios run: | - dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" - dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.ReleaseScenarios*" + dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" + dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.ReleaseScenarios*" - name: Write workflow summary if: always() diff --git a/doc/performance-baseline.md b/doc/performance-baseline.md index f1f4996f..97b2d30a 100644 --- a/doc/performance-baseline.md +++ b/doc/performance-baseline.md @@ -96,9 +96,9 @@ For telemetry and observability features, see [doc/telemetry.md](./telemetry.md) dotnet build --configuration Release # Run performance smoke tests -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj \ +dotnet test --solution DotNetMcp.slnx \ --no-build --configuration Release \ - --filter-namespace "*Performance*" + -- --filter-namespace "*Performance*" ``` ### In CI diff --git a/doc/testing.md b/doc/testing.md index 6fae7463..5db9b4c6 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -35,15 +35,15 @@ Install the exact .NET 11 RC3 SDK pinned in `global.json` and the .NET 10 SDK/ru Run all tests (recommended): ```bash -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release +dotnet test --solution DotNetMcp.slnx -c Release ``` Important: -- When specifying a project for `dotnet test`, use `--project` (do not pass a `.csproj` as a positional argument). If you pass a project path positionally, `dotnet test` will emit: `Specifying a project for 'dotnet test' should be via '--project'`. -- When running from the solution, use `--solution`. +- Use `--solution DotNetMcp.slnx` for this repository. The pinned .NET 11 RC3 SDK has a `--project` discovery regression that can report no test projects or duplicate the project path before tests run. +- Solution discovery avoids that SDK regression while preserving both target frameworks, MTP filters, and coverage options. Do not replace it with a positional project path. -### Why `--project`? +### Why `--solution`? This repository uses the **Microsoft Testing Platform (MTP)** as configured in `global.json`: @@ -55,6 +55,8 @@ This repository uses the **Microsoft Testing Platform (MTP)** as configured in ` } ``` +Both server and test projects are in `DotNetMcp.slnx`. Solution-based discovery runs the same test project without the pinned SDK's broken project-discovery path. The general runner compatibility information below describes the MCP server's Test action, not the entry point to use for this repository's own tests. + #### Test Runner Compatibility The `--project` flag support depends on which test runner is being used: @@ -112,13 +114,6 @@ The MCP server chooses between `--project` flag (MTP) and positional argument (V - `projectArgumentStyle`: `--project`, `positional`, or `none` - `selectionSource`: `global.json`, `testRunner-parameter`, `useLegacyProjectArgument-parameter`, or `default` -Examples: - -```bash -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -dotnet test --solution DotNetMcp.slnx -c Release -``` - Run tests from the solution: ```bash @@ -132,7 +127,7 @@ Both projects use matching MCP SDK and extension versions. The SDK 2.x compatibi Run the focused protocol matrix: ```powershell -dotnet test --project .\DotNetMcp.Tests\DotNetMcp.Tests.csproj -c Release -- --filter-class '*Sdk20CompatibilityTests' --filter-class '*ServerCapabilitiesTests' +dotnet test --solution DotNetMcp.slnx -c Release -- --filter-class '*Sdk20CompatibilityTests' --filter-class '*ServerCapabilitiesTests' ``` `Sdk20CompatibilityTests` covers 2026-07-28 and 2025-11-25 discovery, required tool input schemas, negotiated capabilities, resource error-code mapping, native/legacy resource-update delivery, native listener cancellation, confirmation outcomes and continuation validation, execution after confirmation, Tasks polling/update/cancellation, and governance policy composition. Deprecated-feature regressions cover logging thresholds and notification payloads, request-level logging/Sampling isolation, connected legacy Roots discovery and explicit-path precedence, and Sampling analysis of failures with successful-command and unsupported-client bypass. Cancellation coverage includes pending Roots/Sampling input and termination of a real CLI child process without subsequent AI analysis. The full-catalog governance test intentionally verifies fail-closed rejection of the existing certificate password schema; it is not evidence that governance-enabled full-catalog startup succeeds. @@ -146,7 +141,7 @@ The Tasks capability matrix includes servers with and without `WithTasks`, legac Run the focused real-stdio Tasks checks: ```powershell -dotnet test --project .\DotNetMcp.Tests\DotNetMcp.Tests.csproj -c Release -- --filter-class '*McpConformanceTests' --filter-method '*Task*' +dotnet test --solution DotNetMcp.slnx -c Release -- --filter-class '*McpConformanceTests' --filter-method '*Task*' ``` Focused error regressions distinguish SDK wire errors from application annotations: missing resource reads produce `-32602` on the current revision and `-32002` on the legacy revision, while factory-generated tool errors retain their annotations, `IsError`, object envelopes, and equivalent structured/text JSON content on both. Unit tests cover all five missing-resource diagnostic mappings, both capability factory overloads, and separation from the SDK's renumbered `-32020`/`-32021`/`-32022` codes. @@ -160,7 +155,7 @@ MTP selectors of the same kind can be repeated to match multiple classes or meth `OutputSchemaTests` obtains the production schemas through actual `tools/list` calls and validates structured responses on both MCP 2026-07-28 and 2025-11-25. Coverage includes all six schema-bearing tools, action-restricted text fallbacks, domain metadata, empty/non-empty lists, diagnostic failures, capability/validation errors, optional runtime enrichment, lock contention, and object envelopes without a new `result` wrapper. Deterministic command producers avoid network-dependent package operations; project metadata fixtures are isolated and deleted after each test. Compatibility checks preserve the first text block and require serialized JSON text matching the payload. Negative schema cases reject missing fields, incorrect nested types, and fallback misuse. Production stdio conformance tests also verify that returned application errors increment failure metrics rather than success metrics. ```powershell -dotnet test --project .\DotNetMcp.Tests\DotNetMcp.Tests.csproj -- --filter-class '*OutputSchemaTests' --filter-class '*StructuredContentTests' --filter-class '*ServerMetricsToolTests' +dotnet test --solution DotNetMcp.slnx -- --filter-class '*OutputSchemaTests' --filter-class '*StructuredContentTests' --filter-class '*ServerMetricsToolTests' ``` ## Test isolation and runtime dependencies @@ -174,10 +169,10 @@ An SDK project with no target framework can either complete validation (`success CI remains Ubuntu-only; PR checks run `ProjectAnalysisHelperTests` alongside MCP conformance tests, and main runs them in the full suite. The same portable tests can run on-device on Windows or macOS with the same class selector. For example, from a Windows checkout: ```powershell -dotnet test --project .\DotNetMcp.Tests\DotNetMcp.Tests.csproj -c Release -- --filter-class '*ProjectAnalysisHelperTests' +dotnet test --solution DotNetMcp.slnx -c Release -- --filter-class '*ProjectAnalysisHelperTests' ``` -On macOS or Linux, pass the local test-project path to `--project` and keep the same selector. Each platform runs all fixtures and selects assertions based on its actual evaluation result. +On macOS or Linux, use the same solution command and selector from the repository root. Each platform runs all fixtures and selects assertions based on its actual evaluation result. In-process MSBuild analysis requires runtime assets compatible with the project's target framework. Keep `Microsoft.Build` and `Microsoft.Build.Utilities.Core` aligned on a .NET 10-compatible release, and retain the explicit `NuGet.Frameworks` dependency needed by MSBuild property functions rather than relying on the older version supplied by TemplateEngine. @@ -194,7 +189,7 @@ Run scenario tests locally: ```powershell $env:DOTNET_MCP_SCENARIO_TESTS = "1" -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" +dotnet test --solution DotNetMcp.slnx -c Release -- --filter-namespace "*DotNetMcp.Tests.Scenarios*" ``` ### Per-test diagnostics with ITestOutputHelper @@ -279,7 +274,7 @@ The repository includes conformance tests that validate the server's compliance To run only the conformance tests: ```bash -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -- --filter-class "*McpConformanceTests" +dotnet test --solution DotNetMcp.slnx -c Release -- --filter-class "*McpConformanceTests" ``` ### What Conformance Tests Validate @@ -316,7 +311,7 @@ Conformance tests run automatically in GitHub Actions as part of the `build.yml` To collect coverage with Microsoft Testing Platform, run: ```bash -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -- --coverage --coverage-output-format cobertura +dotnet test --solution DotNetMcp.slnx -c Release -- --coverage --coverage-output-format cobertura ``` The Cobertura XML will be written under the test output folder, typically: @@ -527,13 +522,13 @@ PowerShell: ```powershell $env:DOTNET_MCP_INTERACTIVE_TESTS = "1" -dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release +dotnet test --solution DotNetMcp.slnx -c Release ``` bash: ```bash -DOTNET_MCP_INTERACTIVE_TESTS=1 dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release +DOTNET_MCP_INTERACTIVE_TESTS=1 dotnet test --solution DotNetMcp.slnx -c Release ``` If interactive tests are disabled, they will appear as skipped with a message explaining how to enable them. @@ -578,7 +573,7 @@ Avoid creating redundant tests that only differ by the `machineReadable` flag un ## Tips - Prefer `-c Release` for CI parity. -- If you're iterating on a single area, use Microsoft Testing Platform filters after `--`, for example: `dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -- --filter-class DotNetMcp.Tests.CacheMetricsTests`. +- If you're iterating on a single area, use Microsoft Testing Platform filters after `--`, for example: `dotnet test --solution DotNetMcp.slnx -c Release -- --filter-class DotNetMcp.Tests.CacheMetricsTests`. ## Path handling diff --git a/scripts/run-release-gate-tests.ps1 b/scripts/run-release-gate-tests.ps1 index 4fbfe0cd..e7ae9f6f 100644 --- a/scripts/run-release-gate-tests.ps1 +++ b/scripts/run-release-gate-tests.ps1 @@ -47,7 +47,7 @@ try { $baseTestArgs = @( 'test', - '--project', 'DotNetMcp.Tests/DotNetMcp.Tests.csproj', + '--solution', 'DotNetMcp.slnx', '--configuration', $Configuration, '--verbosity', 'normal' ) diff --git a/scripts/validate-coverage-exclusions.ps1 b/scripts/validate-coverage-exclusions.ps1 index caaabfd9..41fd5b34 100644 --- a/scripts/validate-coverage-exclusions.ps1 +++ b/scripts/validate-coverage-exclusions.ps1 @@ -103,7 +103,7 @@ if (-not $CoverageFile) { if ($coverageFiles.Count -eq 0) { Write-Warning "No coverage files found. Run tests with coverage first:" - Write-Host " dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj -c Release -- --coverage --coverage-output-format cobertura" + Write-Host " dotnet test --solution DotNetMcp.slnx -c Release -- --coverage --coverage-output-format cobertura" exit 0 }