Skip to content

Drop Mono fallback, run .NET Framework tests on Windows only - #16158

Merged
Jakub Jareš (nohwnd) merged 2 commits into
microsoft:mainfrom
nohwnd:fix/15340-drop-mono-netfx-testhost
Jun 29, 2026
Merged

Drop Mono fallback, run .NET Framework tests on Windows only#16158
Jakub Jareš (nohwnd) merged 2 commits into
microsoft:mainfrom
nohwnd:fix/15340-drop-mono-netfx-testhost

Conversation

@nohwnd

Copy link
Copy Markdown
Member

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 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 (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:

Running .NET Framework tests is supported on Windows only.

Running .NET Framework tests on this operating system relied on Mono, which is no longer supported. To run these tests, run them on Windows, or change the test project to target .NET instead of .NET Framework.

.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, DefaultTestHostManagerTests pass 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.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 DefaultTestHostManager to 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

Comment thread src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs Outdated
- 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>
@nohwnd

Copy link
Copy Markdown
Member Author

18.10?

@nohwnd
Jakub Jareš (nohwnd) enabled auto-merge (squash) June 29, 2026 12:38
@nohwnd
Jakub Jareš (nohwnd) merged commit 17971a0 into microsoft:main Jun 29, 2026
27 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9.0.112 VSTest is busted on mono

3 participants