Skip to content

fix(tests): normalize test SDK + restore OutputType=Exe for MTP - #331

Merged
2 commits merged into
mainfrom
fix/tests-sdk-normalization
May 12, 2026
Merged

fix(tests): normalize test SDK + restore OutputType=Exe for MTP#331
2 commits merged into
mainfrom
fix/tests-sdk-normalization

Conversation

@ANcpLua

@ANcpLua ANcpLua commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Switch `qyl.mcp.tests` from `ANcpLua.NET.Sdk` → `ANcpLua.NET.Sdk.Test` (14b3246a)
  • Switch `qyl.collector.tests` from `ANcpLua.NET.Sdk.Web` → `ANcpLua.NET.Sdk.Test` (14b3246a)
  • Restore explicit `Exe` in both csprojs (3d12f9a5) — regression fix

Why the SDK switch is safe for collector.tests

`ANcpLua.NET.Sdk.Test` is based on `Microsoft.NET.Sdk` (not `.Web`). `Microsoft.AspNetCore.Mvc.Testing` auto-adds the `Microsoft.AspNetCore.App` framework reference since .NET 6, so the `.Web` base SDK is not required. Build + test confirm both projects compile and run.

Why OutputType=Exe must stay explicit

`Tests.targets` in `ANcpLua.NET.Sdk` sets `OutputType=Exe` inside the `_DetectTestFrameworksAndMTP` Target. Targets fire at build time, but `dotnet test` evaluates `OutputType` statically before invoking the test platform — sees `Library`, aborts:

A runnable project should target a runnable TFM (for instance, net10.0) and have OutputType 'Exe'. The current OutputType is 'Library'.

Setting `Exe` in the csproj evaluates during the props phase, so both `dotnet build` and `dotnet test` see `Exe` before any target runs. The .Test variant SDK auto-sets `IsTestProject=true` (via `Common.props` line 10), so that property is no longer needed in either csproj — but `OutputType` is.

Why `xunit.v3.mtp-v2` stays referenced

`Tests.targets` auto-injects `xunit.v3.mtp-v2` with `IsImplicitlyDefined="true"` and an explicit `Version`. Under CPM with `xunit.v3.mtp-v2` listed in `Directory.Packages.props`, this combination produces `NU1009` ("implicitly defined items cannot define a PackageVersion"). Until the SDK itself is fixed, consumers using CPM must keep an explicit `` to satisfy CPM resolution.

Test plan

  • `dotnet build tests/qyl.mcp.tests/qyl.mcp.tests.csproj` — 0 errors
  • `dotnet build tests/qyl.collector.tests/qyl.collector.tests.csproj` — 0 errors
  • `dotnet test --project tests/qyl.mcp.tests/qyl.mcp.tests.csproj` — 2/2 passed
  • `dotnet test --project tests/qyl.collector.tests/qyl.collector.tests.csproj` — 9/10 passed (1 unrelated meta-check failure from untracked `.agents/` dir in local tree; CI runs on clean checkout)
  • CI green

Follow-up (separate)

The SDK's `Tests.targets` xUnit auto-injection is broken under CPM (NU1009). Fix in `ANcpLua.NET.Sdk`: drop `Version=` from the implicit `PackageReference` when CPM is enabled, or drop `IsImplicitlyDefined`. Will track in the SDK repo.

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

ANcpLua and others added 2 commits May 12, 2026 14:08
The prior normalization commit removed the explicit <OutputType>Exe/> in
favor of Tests.targets auto-setting it. That auto-set runs inside the
_DetectTestFrameworksAndMTP Target, which fires only at build time —
'dotnet test' evaluates OutputType statically before that and aborts with
"A runnable project should target a runnable TFM ... The current
OutputType is 'Library'." MTP also requires the .exe host, not a .dll
library output.

Setting OutputType=Exe in the csproj evaluates during props phase, so
both 'dotnet build' and 'dotnet test' see Exe before any target runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 12, 2026 12:17

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved by destructive auto-merge (admin tier)

@ghost
ghost merged commit 7e1e0e6 into main May 12, 2026
13 of 16 checks passed
@github-actions

Copy link
Copy Markdown

@coderabbitai autofix

@ghost
ghost deleted the fix/tests-sdk-normalization branch May 12, 2026 12:17

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved by destructive auto-merge (admin tier)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Low risk: test project SDK normalization/config-only changes; no runtime/production code paths touched.

Review Notes

Blockers: None found.
Important issues: None found.
Minor / optional: None found.

No blockers were found after checking CI/test integrity implications (MTP runner + OutputType), correctness of project configuration, duplication/unnecessary complexity, and security boundaries (no workflow/secret/auth changes).

Changes:

  • Switch qyl.mcp.tests to ANcpLua.NET.Sdk.Test and rely on the SDK for IsTestProject.
  • Switch qyl.collector.tests to ANcpLua.NET.Sdk.Test and rely on the SDK for IsTestProject.
  • Keep explicit <OutputType>Exe</OutputType> in both test projects to preserve Microsoft Testing Platform (dotnet test) behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/qyl.mcp.tests/qyl.mcp.tests.csproj Move to ANcpLua.NET.Sdk.Test; keep OutputType=Exe for MTP.
tests/qyl.collector.tests/qyl.collector.tests.csproj Move to ANcpLua.NET.Sdk.Test; keep OutputType=Exe for MTP.

@ANcpLua
ANcpLua restored the fix/tests-sdk-normalization branch May 12, 2026 12:22
@ghost
ghost deleted the fix/tests-sdk-normalization branch May 12, 2026 12:22
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants