migrate-vstest-to-mtp
Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing MTP properties and OutputType=Exe on test projects via MSBuildProjectName, not IsTestProject. Suppo
npx skills add dotnet/skills --skill migrate-vstest-to-mtp --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Guides the migration of .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). It describes enabling MTP runners for MSTest, NUnit, and xUnit.net (v2 via YTest.MTP.XUnit2 or v3 with native MTP), centralizing OutputType Exe in Directory.Build.props, updating dotnet test integration, translating VSTest CLI arguments to MTP equivalents, installing necessary MTP extension packages, and updating CI/CD pipelines. It also notes behavioral differences (e.g., zero tests -> exit code 8) and provides strategies to ignore that exit code or configure it via properties or environment variables. The workflow emphasizes avoiding mixing VSTest and MTP in the same solution and recommends adopting a centralized Directory.Build.props approach rather than per-project settings where possible.
How it works
- Identifies test frameworks per project (MSTest, NUnit, xUnit.net v2 or v3) and the appropriate MTP runner enablement.
- Recommends centralizing MTP-related OutputType changes in Directory.Build.props using a MSBuildProjectName-based condition to target test projects.
- Provides framework-specific enabling steps, including XML PropertyGroup blocks to set EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner, and corresponding OutputType adjustments.
- Details how to configure dotnet test integration for .NET 10+ (global.json test runner) or .NET 9 and earlier (TestingPlatformDotnetTestSupport flag) and how to translate CLI arguments from VSTest to MTP equivalents.
- Lists the MTP extension packages needed for TRX, crash/hang dumps, and code coverage, with example PackageReference entries.
- Describes CI/CD migration steps (Azure DevOps, GitHub Actions) and how to replace vstest.console.exe with dotnet test.
- Addresses exit-code differences (zero tests -> exit code 8) and provides multiple approaches to ignore or handle the code via command-line, property, or environment variable.
When to use it
- When switching from VSTest to MTP for supported test frameworks.
- When enabling dotnet run / dotnet watch / direct executable execution for test projects.
- When replacing vstest.console.exe with dotnet test in CI/CD or local runs.
- When updating CI/CD pipelines to use MTP-compatible runners and syntax.
What it can touch
- Directory.Build.props (for central MTP runner enablement and OutputType) and per-project conditionals based on MSBuildProjectName.
- Project files with MSTest, NUnit, and xUnit.net dependencies to enable appropriate MTP runners.
- global.json (for SDK version 10+ runner mode) and dotnet test arguments in CI configurations.
- CI/CD pipelines (Azure DevOps, GitHub Actions) commands and scripts.
- Optional PackageReference entries for TRX, CrashDump, HangDump, and CodeCoverage extensions.
Caveats
- Do not mix VSTest-based and MTP-based test projects within the same solution or run configuration.
- xUnit.net v3 on MTP does not support the VSTest --filter syntax; translation to native xUnit.net v3 filters is required.
- Some steps rely on naming conventions for test projects (e.g., ending with .Tests) to centrally apply OutputType Exe.
- Removing UseVSTest may be required when MSTest.Sdk is not used; ensure compatibility with your project setup.
# VSTest -> Microsoft.Testing.Platform Migration Migrate a .NET test solution from VSTest to Microsoft.Testing.Platform (MTP). The outcome is a solution where all test projects run on MTP, `dotnet test` works correctly, and CI/CD pipelines are updated. > **Important**: Do not mix VSTest-based and MTP-based .NET test projects in the same solution or run configuration -- this is an unsupported scenario. ## When to Use - Switching from VSTest to Microsoft.Testing.Platform for any supported test framework - Enabling `dotnet run` / `dotnet watch` / direct executable execution for test projects - Enabling Native AOT or trimmed test execution - Replacing `vstest.console.exe` with `dotnet test` on MTP - Updating CI/CD pipelines from the VSTest task to the .NET Core CLI task - Updating `dotnet test` arguments from VSTest syntax to MTP syntax ## When Not to Use - The project already runs on Microsoft.Testing.Platform and there is no remaining MTP behavioral difference to resolve (e.g., exit code 8 for zero tests discovered) - Migrating between test frameworks (e.g., MSTest to xUnit.net) -- different effort entirely - The project builds UWP or packaged WinUI test projects -- MTP does not supp
- When to Use
- When Not to Use
- Inputs
- Workflow
- Step 1: Assess the solution
- Step 2: Set up Directory.Build.props
- Step 3: Enable the framework-specific MTP runner
- Step 4: Configure dotnet test integration
- Step 5: Update dotnet test command-line arguments
- Step 6: Install MTP extension packages (if needed)
- Step 7: Update CI/CD pipelines
- Step 8: Handle behavioral differences
- Step 9: Remove VSTest-only packages (optional)
- Step 10: Verify
VSTest dotnet test --filter "FullyQualifiedName~IntegrationTests&Category=Smoke" xUnit.net v3 MTP -- using individual filters (AND behavior) dotnet test -- --filter-class *IntegrationTests* --filter-trait "Category=Smoke" xUnit.net v3 MTP -- using query language (assembly/namespace/class/method[trait]) dotnet test -- --filter-query "/*/*/*IntegrationTests*/*[Category=Smoke]"
What does the migrate-vstest-to-mtp skill do?
Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing MTP properties and OutputType=Exe on test projects via MSBuildProjectName, not IsTestProject. Suppo
How do I install it?
Run `npx skills add dotnet/skills --skill migrate-vstest-to-mtp --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
