Skip to content

Fix native dotnet test routing for packaged applications - #11804

Merged
Amaury Levé (Evangelink) merged 2 commits into
microsoft:mainfrom
Sergio0694:user/sergiopedri/sidecar-dotnet-test-routing
Oct 8, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
microsoft:mainfrom
Sergio0694:user/sergiopedri/sidecar-dotnet-test-routing

Conversation

@Sergio0694

@Sergio0694 Sergio Pedri (Sergio0694) commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Native .NET 10 dotnet test reads RunCommand/RunArguments from a fresh ComputeRunArguments evaluation, not the executable/environment items used by InvokeTestingPlatform. Route packaged full-trust .NET applications through the existing sidecar in that path, including clean builds and --no-build, using a versioned startup prefix that preserves the selected executable, enabled extensions, and argument tail.

Only the activated test host connects to the SDK pipe, so it reports its real runtime/architecture rather than conflicting with the external controller's identity. Preserve the execution-ID handoff, retry transport, selected-host results, failure exit codes and on-disk TRX reports. Native help/discovery activate the actual host instead of describing the dummy framework. Preserve explicit executable/run-command overrides and unpackaged execution; document the corresponding packaged dotnet run behavior and explicit native AppContainer rejection (use the working MSBuild path).

Scope: framework-specific option registration, including MSTest's --filter, is implemented in the dependent #11805. Routing and that registration fix should ship together. The filter branch is based on this PR's pushed commit; both PRs target upstream main as requested because the parent branch exists only in the fork, so #11805's diff is cumulative until this PR merges. Controller-generated reports are written on disk, not advertised as artifacts to the native SDK. SDK 10's help/startup limitations and informational-host teardown limitations are documented.

Validation (Windows x64; source packages 4.6.0-dev/2.6.0-dev; generated assets explicitly pin SDK 10.0.401):

Command Result
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\eng\build.ps1 -restore -build -bl -msbuildEngine dotnet -projects artifacts\tmp\RoutingValidation\RoutingValidation.slnx /p:SkipUapTargetFramework=true Passed; focused generated solution, 0 warnings/errors.
.\.dotnet\dotnet.exe artifacts\bin\Microsoft.Testing.Extensions.UnitTests\Debug\net8.0\Microsoft.Testing.Extensions.UnitTests.dll --filter 'FullyQualifiedName~PackagedApp' --progress off 160 passed, 2 existing OS-conditioned skips, 0 failed.
& "$root\.dotnet\dotnet.exe" "$root\artifacts\bin\MSTest.Acceptance.IntegrationTests\Debug\net11.0\MSTest.Acceptance.IntegrationTests.dll" --filter 'FullyQualifiedName~PackagedAppNativeDotnetTestTests|FullyQualifiedName~PackagedAppIntegrationTests' --progress off All 79 passed; $root was a temporary short-path alias of this same worktree to avoid the existing long package-cache path limit.
.\.dotnet\dotnet.exe msbuild src\Platform\Microsoft.Testing.Extensions.PackagedApp\Microsoft.Testing.Extensions.PackagedApp.csproj -t:UpdateXlf -bl:artifacts\log\Debug\Routing-UpdateXlf2.binlog -v:minimal Passed; XLF files regenerated, not hand-edited.
.\build.cmd -pack -bl -msbuildEngine dotnet -projects artifacts\tmp\RoutingValidation\RoutingValidation.slnx /p:SkipUapTargetFramework=true (and equivalent eng\build.ps1 -restore -build -pack -bl repack) Product compilation and required package generation completed. Final whole-package audit failed because excluded UAP assets reduce the expected MSTest/TestAdapter/TestFramework file counts; legacy Windows SDK 16299 provisioning failed.

The lightweight packaged fixture requires Package.Current in a module initializer and needs no WinUI/Visual Studio workload. It verifies --project and positional invocations, clean/no-build, .NET 8/.NET 10 hosts, actual package/execution identity, pass/fail results, exact TRX test outcomes, retries, actual help/discovery, disabled/AppContainer rejection, and dotnet run. Disabling routing reproduces the original identity-required startup failure with zero tests.

ARM64/x86 execution, other native SDK versions, end-to-end Ctrl+C, and full UAP package validation were not run. No GitHub issue was supplied with the reproduction handoffs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 00:22
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 8, 2026

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.

🔵 Needs a closer look

The process-launch and SDK IPC changes require human review given the unvalidated architectures, SDK versions, and end-to-end cancellation path.

0 open findings

What changed in this PR

Routes native .NET 10 test and run commands for packaged full-trust applications through the packaged-app sidecar.

Changes:

  • Adds versioned controller argument and native SDK pipe routing.
  • Handles informational launches, cancellation, retries, and AppContainer rejection.
  • Adds comprehensive unit/acceptance coverage, localization, and documentation.
File Description
test/​UnitTests/​Microsoft.Testing.Extensions.UnitTests/​PackagedAppNativeInformationalLaunchTests.cs Tests informational launch lifecycle.
test/​UnitTests/​Microsoft.Testing.Extensions.UnitTests/​PackagedAppControllerArgumentsTests.cs Tests bootstrap and transport parsing.
test/​IntegrationTests/​MSTest.Acceptance.IntegrationTests/​PackagedAppNativeDotnetTestTests.cs Exercises native packaged test scenarios.
test/​IntegrationTests/​MSTest.Acceptance.IntegrationTests/​PackagedAppIntegrationTests.cs Tests computed run contracts and overrides.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​ExtensionResources.resx Adds controller errors.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.cs.xlf Updates Czech catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.de.xlf Updates German catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.es.xlf Updates Spanish catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.fr.xlf Updates French catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.it.xlf Updates Italian catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.ja.xlf Updates Japanese catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.ko.xlf Updates Korean catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.pl.xlf Updates Polish catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.pt-BR.xlf Updates Portuguese catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.ru.xlf Updates Russian catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.tr.xlf Updates Turkish catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.zh-Hans.xlf Updates Simplified Chinese catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​Resources/​xlf/​ExtensionResources.zh-Hant.xlf Updates Traditional Chinese catalog.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​PackagedAppTestHostLauncher.PackagedLaunch.cs Rejects native AppContainer launches.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​PackagedAppTestHostLauncher.LooseLayout.cs Prevents stale native transport inheritance.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​PackagedAppTestHostLauncher.cs Forwards native transport to the host.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​PackagedAppNativeInformationalLaunch.cs Implements help/discovery host lifecycle.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​PackagedAppControllerArguments.cs Implements the startup protocol.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp/​InternalAPI/​InternalAPI.Unshipped.txt Tracks new internal APIs.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp.MSBuild/​PACKAGE.md Documents native routing behavior.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp.MSBuild/​buildTransitive/​Microsoft.Testing.Extensions.PackagedApp.MSBuild.targets Rewrites computed launch properties.
src/​Platform/​Microsoft.Testing.Extensions.PackagedApp.Controller/​Program.cs Integrates routing into the controller.
docs/​winui-testing.md Documents WinUI behavior and limitations.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@github-actions

This comment has been minimized.

@Evangelink Amaury Levé (Evangelink) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note

Automated review by GitHub Copilot. To request a follow-up action, reply by tagging @copilot directly.

Review outcome: Two reproduced P2 regressions in the newly routed dotnet run path need correction before I can recommend approval. Both were confirmed with SDK 10.0.401, freshly packed 4.6.0-dev / 2.6.0-dev components, and an actual full-trust package whose module initializer requires Package.Current.

Reviewer actions: Preserve launch-profile argument handling, and activate the selected host for informational dotnet run requests. Add acceptance cases for profile-only arguments, explicit-argument precedence, and dotnet run -- --list-tests / --help. The inline comments contain the reproductions and expected outcomes.

Confidence at a glance

🟡 MSBuild and SDK launch integration — launch-profile arguments are lost

Reviewed fresh ComputeRunArguments evaluation, clean/no-build execution, staged executable selection, explicit overrides, and .NET 10 SDK argument precedence. A profile requiring three tests silently exits 0 with only one test; the identical explicit argument tail exits 9. See the inline finding on the bootstrap argument assignment.

🟡 Controller, transport and lifecycle — non-native discovery crashes

Traced transport stripping/reinjection, execution identity, retries, activation handoff, controller/discovery roles, and cancellation cleanup. Packaged dotnet run -- --list-tests exits -532462766 without activating the host; native dotnet test --list-tests --no-launch-profile on that same package discovers the test and exits 0. See the inline finding on the no-transport return.

🟢 Existing regression coverage and compatibility — baseline checks passed

The scoped extension build and both sidecar TFMs compiled without warnings/errors. All 160 runnable PackagedApp unit cases passed (two existing OS-conditioned skips), and all 79 PackagedApp native/MSBuild acceptance cases passed using newly packed components. Reviewed changed assertions, isolation, resource/XLF parity, internal API tracking, package layout, and documentation alignment. These passing cases do not exercise the two reproduced dotnet run failures.

The focused pack produced the required consumer packages, but its final whole-package audit failed on deliberately excluded UAP files and the omitted UIAutomation project; this is not a full-pack success. End-to-end Ctrl+C, ARM64/x86 execution, and other native SDK versions were not rerun. Keep the already documented filter-registration dependency on #11805; it is not counted as a new finding here.

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: df96a46c-5877-4d2e-abec-187268e68740
Copilot AI balanced review requested due to automatic review settings October 8, 2026 08:41
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026

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.

🔵 Needs a closer look

It introduces cross-package process-launch and IPC behavior, depends on #11805, and lacks ARM64/x86 and broader SDK validation.

0 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Final test-triage resolution — Azure Pipelines build 1627746

Analysis for the microsoft.testfx check is complete (build result: succeeded; full aggregate evidence).

Summary: Out of 107,712 normalized test records, the only non-passing result is PackagedWinUI.PackagedWinUITestCases.RetryTestMethod_PassesOnSecondAppContainerHost, which recorded a failed attempt-1 TRX entry followed by a passed attempt-2 entry in the Windows_App_Model_Diagnostics artifact (Retry sub-folder vP2SH).

Root cause: This is not a regression or flake. The test's source (test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/PackagedWinUITests.cs, RETRY_TEST-guarded method around line 1230) is intentionally written to fail on its first invocation (writes a marker file and calls Assert.Fail) and pass on the second, specifically to validate that the Retry extension activates a second AppContainer host. The outer acceptance assertions (same file, lines ~689–710) validate this exact first-fail/second-pass sequence as the expected outcome.

Historical correlation: All 12 available historical builds in the last 30 days show the identical pattern — attempt 1 failed with the same message/trace, attempt 2 passed — with no variation in signature. This confirms stable, by-design scaffolding rather than an environmental one-off or product defect.

Conclusion: No action needed. No issue is being created — this does not meet the durable-defect, flaky-recovery, or regression thresholds (the fail-then-pass pattern is expected and consistent, not anomalous). No matching open/closed issue search was needed since this is expected behavior, not a candidate signature.

No other actionable test, crash/hang, or duration-regression signals were found in this build's evidence (slowRegressionCount: 0, diagnosticCount: 0, timelineSignalCount: 0).

🤖 Automated content by GitHub Copilot. Generated by the Pipeline Test Triage workflow. · copilot · auto · 53.4 AIC · ⌖ 5.69 AIC · ⊞ 9.7K

@Evangelink

Copy link
Copy Markdown
Member

/backport to rel/4.5

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit cac4b5c into microsoft:main Oct 8, 2026
44 of 45 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the state/needs-review Awaiting review from the team. label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Started backporting to rel/4.5: https://github.com/microsoft/testfx/actions/runs/37768965920

Amaury Levé (Evangelink) added a commit that referenced this pull request Oct 8, 2026
… in #11804 (backport to rel/4.5) (#11818)

Co-authored-by: Sergio Pedri <sergio0694@live.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Amaury Levé <amauryleve@microsoft.com>
Copilot-Session: df96a46c-5877-4d2e-abec-187268e68740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants