Drop Mono fallback, run .NET Framework tests on Windows only - #16158
Merged
Jakub Jareš (nohwnd) merged 2 commits intoJun 29, 2026
Merged
Conversation
The .NET Framework test host (testhost.exe) only runs on Windows. On Linux and
macOS vstest launched it through Mono, but Mono is no longer supported and the
.NET SDK on Linux no longer ships the TestHostNetFramework folder, so dotnet test
on a net462 project failed with an opaque Mono error:
Cannot open assembly '.../TestHostNetFramework/testhost.exe': No such file or directory.
DefaultTestHostManager now throws a clear TestPlatformException when asked to run
on a non-Windows OS instead of falling back to Mono. .NET tests are unaffected,
they go through DotnetTestHostManager.
Breaking change: running .NET Framework tests on Linux or macOS is no longer
supported.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy Mono-based fallback for running .NET Framework (testhost.exe) tests on non-Windows platforms, and instead fails fast with a clear, actionable error message. This aligns runtime behavior with current SDK packaging reality (no TestHostNetFramework on Linux/macOS) and clarifies the supported matrix.
Changes:
- Update
DefaultTestHostManagerto throw a clear “Windows only” error on non-Windows instead of attempting Mono. - Update/adjust unit tests to reflect the new non-Windows behavior.
- Add acceptance coverage for the new failure mode and localize the new resource across all XLF files.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs | Updates unit tests to expect a non-Windows exception rather than Mono hosting behavior. |
| test/Microsoft.TestPlatform.Acceptance.IntegrationTests/FrameworkTests.cs | Adds acceptance coverage for the “Windows only” error when forcing .NET Framework host on non-Windows. |
| src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs | Removes Mono fallback and throws a clear non-Windows error for .NET Framework host execution. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.resx | Adds new localized resource string for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.Designer.cs | Exposes the new resource via the generated designer property. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.cs.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.de.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.es.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.fr.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.it.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ja.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ko.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pl.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pt-BR.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ru.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.tr.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hans.xlf | Adds new trans-unit entry for the “Windows only” message. |
| src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hant.xlf | Adds new trans-unit entry for the “Windows only” message. |
Files not reviewed (1)
- src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.Designer.cs: Generated file
- Throw the resource string directly instead of string.Format with no args (avoids a latent FormatException if a translation ever adds braces). - Unit test asserts the full "supported on Windows only" sentence, not just "Windows". - Acceptance test asserts ExitCodeEquals(1) on non-Windows to prove the run fails fast, not just logs a warning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
18.10? |
Jakub Jareš (nohwnd)
enabled auto-merge (squash)
June 29, 2026 12:38
Amaury Levé (Evangelink)
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15340.
The .NET Framework test host (
testhost.exe) only runs on Windows. On Linux and macOS vstest launched it through Mono, but Mono is no longer supported, and the .NET SDK on Linux no longer ships theTestHostNetFrameworkfolder — sodotnet teston anet462project failed with an opaque Mono error:DefaultTestHostManager(the .NET Framework host) now throws a clear error when it is about to run on a non-Windows OS, instead of falling back to Mono:.NET tests are unaffected — they go through
DotnetTestHostManager.Breaking change: running .NET Framework tests on Linux or macOS is no longer supported. As discussed in the issue, anyone running them there also has a Windows leg, so the Mono path is not worth keeping.
Verified: full Debug build green,
DefaultTestHostManagerTestspass on net481 and net11.0. Added an acceptance test that forces the .NET Framework host and asserts the clear error on non-Windows.Replaces #16130, which only improved the error message but still ran Mono when the host happened to be present.