vstest icon indicating copy to clipboard operation
vstest copied to clipboard

Consider not redistributing testhost.exe and friends on .NET 11+

Open baronfel opened this issue 2 months ago • 7 comments

Per https://github.com/dotnet/sdk/pull/48599#issuecomment-3127415278 we should consider not explicitly copying testhost.exe to the output directories of builds on Windows hosts.

baronfel avatar Nov 05 '25 15:11 baronfel

Eh, we have a hack in MSTest that might get broken with this.

https://github.com/microsoft/testfx/blob/8687e54f761bba78da213cd5ff34562dca3f8945/src/Adapter/MSTestAdapter.PlatformServices/Services/MSTestAdapterSettings.cs#L190-L199

Youssef1313 avatar Nov 05 '25 15:11 Youssef1313

I was talking about these here:

Image

For .NET.

We still need to copy testhost*.exe for .net framework, because we don't have other way there to run tests. The hack talks about appdomains - do .net framework only? :)

nohwnd avatar Nov 05 '25 15:11 nohwnd

Ah okay right. Those should be fine then :)

Youssef1313 avatar Nov 05 '25 16:11 Youssef1313

@nohwnd Thinking again here. With the current setup, people can have just x64 dotnet.exe installed, and they can run their tests under testhost.x86.exe. If we don't ship that, then I assume we will be under dotnet.exe process. But if there is no x86 dotnet.exe is available, and user is requesting to run under x86, we will be broken. Right?

Youssef1313 avatar Nov 11 '25 12:11 Youssef1313

The testhost exes are not self-contained, so they will have to have an x86 installation of .net runtime on their system either way.

Those testhost exes have only 2 purposes:

  1. make the name of the process easier to "read" (we run in testhost.exe rather than in dotnet.exe
  2. find different architecture of dotnet using the rules that are built into that native testhost.x86.exe muxer, rather than via the logic that duplicates the muxer logic that searches for the appropriate dotnet.exe in DotnetRuntimeProvider.

nohwnd avatar Nov 11 '25 13:11 nohwnd

they will have to have an x86 installation of .net runtime

But not necessarily having x86 installation of SDK?

Youssef1313 avatar Nov 11 '25 13:11 Youssef1313

Yes, and that is true also today.

You need some dotnet sdk to have vstest.console. And the console will offload work to testhost processes with the selected platform, you can select this platform per project (via RID), so in the most complex case on ARM64 device, you can have some projects running natively as arm64, some as x86 and some as x64. This would require having arm64, x86 and x64 runtimes on the system.

Those testhost processes can start as dotnet.exe, or as testhost.*.exe, depending on what is found.

nohwnd avatar Nov 11 '25 13:11 nohwnd