Repository navigation
Description
Describe the bug
Starting with Microsoft.Testing.Platform.MSBuild 2.5.0 (MSTest.Sdk 4.5.0), running tests through the MSBuild integration fails when the test app runs under a test host controller. This covers dotnet build -t:Test and the InvokeTestingPlatform target. TRX reporting always uses a controller, so --report-trx triggers the failure. --hangdump and --crashdump fail the same way. The build reports:
error : MSBuild extension failed to receive test application information from '<path>/Repro.dll'
The same project passes on MSTest.Sdk 4.4.1 (MTP.MSBuild 2.4.1). On 4.5.1 it also passes when no controller-backed option is used. Running the app directly, or using dotnet test in Microsoft.Testing.Platform mode with --report-trx, works on 4.5.1. Only the MSBuild -t:Test / InvokeTestingPlatform path is affected.
Version used
- MSTest.Sdk 4.5.1, which brings Microsoft.Testing.Platform / Microsoft.Testing.Platform.MSBuild 2.5.1
- Last known good: MSTest.Sdk 4.4.1 (MTP.MSBuild 2.4.1)
- First bad: MTP.MSBuild 2.5.0. I confirmed it with MSTest.Sdk 4.4.1 plus an explicit
PackageReferencetoMicrosoft.Testing.Platform.MSBuild2.5.0. MSTest.Sdk 4.4.1 with Microsoft.Testing.Platform 2.5.0 but MTP.MSBuild 2.4.1 passes. - .NET SDK 10.0.402 (runtime 10.0.13), Linux x64 (Azure Linux 3.0)
Steps To Reproduce
Create the three files below in an empty directory that has no Directory.Build.* files above it.
global.json:
{
"sdk": {
"version": "10.0.402",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"MSTest.Sdk": "4.5.1"
}
}Repro.csproj:
<Project Sdk="MSTest.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
</Project>Test1.cs:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Repro;
[TestClass]
public sealed class Test1
{
[TestMethod]
public void Passes()
{
}
}Then run:
dotnet build -t:Test -p:TestingPlatformCommandLineArguments=--report-trxResults:
| MSTest.Sdk | Arguments | Result |
|---|---|---|
| 4.5.1 | --report-trx |
fails |
| 4.5.1 | (none) | passes |
| 4.4.1 | --report-trx |
passes |
| 4.5.1 | --hangdump with -p:EnableMicrosoftTestingExtensionsHangDump=true |
fails |
| 4.5.1 | --crashdump with -p:EnableMicrosoftTestingExtensionsCrashDump=true |
fails |
| 4.4.1 | --hangdump / --crashdump (same properties) |
passes |
Expected behavior
The tests run and a TRX file is produced, as on 4.4.1:
Run tests: '<repro>/bin/Debug/net10.0/Repro.dll' [net10.0|x64]
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 155ms - Repro.dll (net10.0|x64)
Tests succeeded: '<repro>/bin/Debug/net10.0/Repro.dll' [net10.0|x64]
Build succeeded.
Actual behavior
Repro -> <repro>/bin/Debug/net10.0/Repro.dll
Run tests: '<repro>/bin/Debug/net10.0/Repro.dll' [net10.0|x64]
~/.nuget/packages/microsoft.testing.platform.msbuild/2.5.1/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets(500,5): error : MSBuild extension failed to receive test application information from '<repro>/bin/Debug/net10.0/Repro.dll' [<repro>/Repro.csproj]
Build FAILED.
0 Warning(s)
1 Error(s)
Additional context
My analysis, based on reading the v4.5.1 sources:
- The regression was introduced by Enable MTP for UWP and AppContainer Windows apps #11484, which added
TestingPlatformBuilderHook.- When the arguments contain
--internal-testhostcontroller-pid, the hook does not callAddMSBuild(). - Instead it registers only the MSBuild command-line provider.
- The apparent intent is that the controller process reports to MSBuild in a packaged/AppContainer scenario.
- When the arguments contain
TestHostControllersTestHostadds--internal-testhostcontroller-pidto every child test host it starts, not only packaged ones.- TRX always runs through a test host controller (Default TRX to controller-backed recovery #10808), and so do HangDump and CrashDump.
- The resulting sequence:
- The MSBuild task starts
Repro.dll --internal-msbuild-node <pipe> --report-trx. - The controller starts the child host.
- The child skips the MSBuild lifetime callbacks, so it never sends
ModuleInfoRequest. - Nothing relays this information for the non-packaged controller case.
InvokeTestingPlatformTaskends with no module info and logsDidNotReceiveModuleInfo.
- The MSBuild task starts
- To confirm the cause, I used a custom entry point (
GenerateTestingPlatformEntryPoint=false,GenerateSelfRegisteredExtensions=false).Mainregisters MSTest and the TRX provider and callsbuilder.AddMSBuild()unconditionally.- With MSTest.Sdk 4.5.1 and
--report-trx,dotnet build -t:Testthen passes and writes the TRX file.
- The same skip logic is still present on
mainandrel/4.5as of today.
A possible fix: only skip AddMSBuild() in the child when the controller actually relays the MSBuild information, for example only for the packaged/AppContainer path.
Activity