Repository navigation
Description
Summary
An x86 test project still fails to launch its testhost with hostfxr error 0x800700C1 (ERROR_BAD_EXE_FORMAT) when using Microsoft.TestPlatform.TestHost / Microsoft.NET.Test.Sdk 18.9.0-preview-26319-02, run via vstest.console.exe.
The x86 testhost.x86.exe resolves the runtime from a 64-bit .NET install (the one DOTNET_ROOT points at) and then tries to load the x64 hostfxr.dll into the x86 process, which fails with 0x800700C1 (bad image format / architecture mismatch).
This looks like the same regression as the now-closed #15235, which was closed as a duplicate of dotnet/sdk#49436. That SDK issue is marked completed (closed 2025-10-27), but we are still hitting it with the 18.9.0-preview-26319-02 package and via the vstest.console.exe path (not only dotnet test --arch x86). So either the fix has not flowed into this preview of the TestPlatform packages, or the console-host x86 runtime resolution path is not covered by the fix.
Versions
Microsoft.TestPlatform.TestHost=18.9.0-preview-26319-02Microsoft.NET.Test.Sdk=18.9.0-preview-26319-02- Last known-good for the same project:
Microsoft.TestPlatform.TestHost17.6.1/Microsoft.NET.Test.Sdk17.2.0 - Runner:
vstest.console.exe - OS: Windows x64;
DOTNET_ROOTpoints to an x64 .NET install (no separate x86 runtime onDOTNET_ROOT(x86))
Affected project shape
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
</ItemGroup>
</Project>The test assembly is x86 (PlatformTarget x86) on a net8.0 TFM, executed through vstest.console.exe.
Error
Testhost process for source(s) '<path>\Tests.dll' exited with error: Failed to load the dll from [<dotnet-x64-root>\host\fxr\10.0.8\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from <dotnet-x64-root>\host\fxr\10.0.8\hostfxr.dll failed
- Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
Failed to resolve hostfxr.dll [<dotnet-x64-root>\host\fxr\10.0.8\hostfxr.dll]. Error code: 0x80008082
. Please check the diagnostic logs for more information.
Test Run Aborted.
Note the x86 testhost rolls forward to a .NET 10 runtime and resolves the x64 hostfxr.dll (the only one under DOTNET_ROOT), then fails to load it into the x86 process.
Expected
The x86 testhost should resolve and load an x86 runtime/hostfxr.dll (e.g. via DOTNET_ROOT(x86), registry, or default x86 install location), or fail with a clear, actionable diagnostic — not attempt to load the x64 hostfxr.dll into an x86 process.
Notes / ask
- Reverting the test SDK/host to
17.xmakes x86 execution work again, which is how we are unblocking our build for now. - Please confirm whether the [NetTestingE2E][Regression] Error "The library hostfxr.dll was found..." will throw when executing "dotnet test --arch x86 --diag:log1.txt". dotnet/sdk#49436 fix is included in
18.9.0-preview-26319-02, and whether thevstest.console.exe(not justdotnet test) x86 host-resolution path is covered. If not, this is worth investigating as a continuation/incomplete-fix of x86 builds no longer work from 17.14.0 #15235 / [NetTestingE2E][Regression] Error "The library hostfxr.dll was found..." will throw when executing "dotnet test --arch x86 --diag:log1.txt". dotnet/sdk#49436.
Related
- x86 builds no longer work from 17.14.0 #15235 (closed as duplicate)
- [NetTestingE2E][Regression] Error "The library hostfxr.dll was found..." will throw when executing "dotnet test --arch x86 --diag:log1.txt". dotnet/sdk#49436 (closed as completed 2025-10-27)
Activity
Rework microsoft#16151 fix: promote architecture-less DOTNET_ROOT to …
nohwnd commentedon Jun 23, 2026
PR #16156 has been opened by
@azat-msftto address this regression.Root cause (from the PR): When
vstest.console.exeis invoked directly (not viadotnet test), the SDK never setsVSTEST_DOTNET_ROOT_PATH/VSTEST_DOTNET_ROOT_ARCHITECTURE, so the architecture-specificDOTNET_ROOT_<ARCH>is never computed. The x86 testhost then inherits the architecture-lessDOTNET_ROOTfrom the environment, which on a standard x64-only machine points at an x64 install. The x86 apphost applies thatDOTNET_ROOTregardless of its own architecture and loads the x64hostfxr.dll— causing0x800700C1.Fix: When an architecture-specific apphost is launched and the SDK path hint is absent, vstest now promotes the architecture-less
DOTNET_ROOTto the matchingDOTNET_ROOT_<ARCH>(determined by reading the dotnet muxer's PE header) and clears the architecture-less variable so it doesn't contaminate a different-architecture apphost.Only normalize DOTNET_ROOT when it mismatches the testhost architecture
Add E2E regression test for x86 testhost runtime resolution with x64 …
Restore DOTNET_ROOT for legacy (pre-net6) testhosts in direct-invocat…
Merge pull request #3 from azat-msft/fix/16151-x86-testhost-dotnet-ro…
Rework per feedback: keep existing if-branch, derive dotnetRootPath f…
chore(deps): update dependency microsoft.net.test.sdk to v18 🔥 (#6)