Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b060b71
Enable packaged AppContainer controller infrastructure
Evangelink Sep 24, 2026
9010fc3
Wire MSTest SDK app-model sidecar controller
Evangelink Sep 24, 2026
fae8be6
Add MTP Windows app-model acceptance coverage
Evangelink Sep 24, 2026
ced03c3
Enable classic UWP execution through MTP
Evangelink Sep 24, 2026
0fbdfc7
Harden MTP Windows app-model execution
Evangelink Sep 24, 2026
5faad47
Address packaged app security review
Evangelink Sep 24, 2026
a91c179
Use safe handle for AppContainer SID
Evangelink Sep 24, 2026
7663424
Support neutral packaged app dependencies
Evangelink Sep 24, 2026
5765c79
Address app-model portability feedback
Evangelink Sep 24, 2026
1d5862a
Preserve packaged dependency and exit state
Evangelink Sep 24, 2026
7beb27f
Preserve requested packaged executable
Evangelink Sep 24, 2026
572125a
Fix app-model CI regressions
Evangelink Sep 24, 2026
662b233
Fix app-model controller package layout
Evangelink Sep 24, 2026
09a634f
Fix configuration-specific package validation
Evangelink Sep 24, 2026
d455208
Avoid packaging adapter satellites in UWP MTP apps
Evangelink Sep 24, 2026
6dac1a7
Merge main into app-model support
Evangelink Sep 24, 2026
f512078
Preserve AppContainer artifact destinations
Evangelink Sep 24, 2026
a7ac024
Support inline AppContainer directory options
Evangelink Sep 24, 2026
0a1d6d0
Allow GitHub access in test reviewer workflows
Evangelink Sep 24, 2026
b2c1cda
Merge origin/main into app-model support
Evangelink Sep 25, 2026
249fb1c
Restore current directory in TestSourceHost test
Evangelink Sep 25, 2026
2c5c84c
Address app-model review feedback
Evangelink Sep 25, 2026
d8ab20b
Fix classic UWP retry execution
Evangelink Sep 25, 2026
53742a4
Merge branch 'main' into dev/amauryleve/mtp-appcontainer-e2e
Evangelink Sep 27, 2026
eecf8b2
Fix packaged WinUI generated test source
Evangelink Sep 27, 2026
7bac9e7
Address remaining app-model review feedback
Evangelink Sep 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions TestFx.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<Project Path="src/Platform/Microsoft.Testing.Platform.ServerMode.Client.Sources/Microsoft.Testing.Platform.ServerMode.Client.Sources.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj" />
</Folder>
<Folder Name="/src/1 - Packages/">
<Project Path="src/Package/MSTest.Sdk.AppModelController/MSTest.Sdk.AppModelController.csproj" />
</Folder>
<Folder Name="/src/2 - Adapter/">
<Project Path="src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj" />
<Project Path="src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj" />
Expand Down
6 changes: 6 additions & 0 deletions docs/Changelog-Platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)

## Unreleased

### Added

* Enable native Microsoft.Testing.Platform execution for UWP and AppContainer Windows test hosts through a full-trust sidecar controller, including exact package-SID authorization for controller and extension pipes, LocalState artifact recovery, and multi-host Retry activation.

## <a name="2.4.1" />[2.4.1] - 2026-09-15

See full log [of v4.4.0...v4.4.1](https://github.com/microsoft/testfx/compare/v4.4.0...v4.4.1)
Expand Down
6 changes: 6 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)

## Unreleased

### Added

* Run classic UWP, modern UWP, and AppContainer-configured WinUI test applications end to end through Microsoft.Testing.Platform using the MSTest.Sdk app-model sidecar controller, with AUMID activation, exact package-SID IPC authorization, UI-thread tests, TRX, HangDump, Retry, and encrypted activation payloads.

## <a name="4.4.1" />[4.4.1] - 2026-09-15

See full log [of v4.4.0...v4.4.1](https://github.com/microsoft/testfx/compare/v4.4.0...v4.4.1)
Expand Down
10 changes: 5 additions & 5 deletions docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Runner selection uses the following precedence:
| `false` (default) | `true` | NativeAOT | Builds a self-contained MTP test application using `MSTest.SourceGeneration`; only the NativeAOT-compatible extension subset is available |
| `false` (default) | Unset or `false` | ClassicEngine (MSTest runner) | Builds an executable MTP test application and supports the full extension configuration |

When `UseUwp=true`, `UseVSTest` defaults to `true` because true UWP/AppContainer test hosts do not support MTP. WinUI keeps the MTP default; set `UseVSTest=true` only for a packaged WinUI test application.
UWP and WinUI use the MTP default. For a packaged application, MSTest.Sdk starts its full-trust app-model sidecar controller and activates the selected package application as the test host; `UseVSTest=true` remains an explicit legacy opt-in.

`IsTestApplication` controls whether the project is an executable test application or a reusable test library. It defaults to `true`, except for .NET Standard targets where it defaults to `false`. Set it to `false` for a project that contains shared test helpers or inherited tests and is referenced by an executable test project:

Expand All @@ -315,7 +315,7 @@ In ClassicEngine and VSTest modes, test libraries receive `MSTest.TestFramework`
| `AllMicrosoft` | Everything in `Default`, plus CrashDump, HangDump, HotReload, Retry, AzureDevOpsReport, GitHubActionsReport, HtmlReport, and Fakes |
| `None` | No extensions |

Set an individual `Enable*` property to `false` to remove an extension supplied by a ClassicEngine profile, or to `true` to opt into an extension independently. CtrfReport and JUnitReport are experimental opt-ins; OpenTelemetry is also opt-in. None are enabled by any profile. `EnableMicrosoftTestingExtensionsPackagedApp` is independent of profiles and defaults to `true` for a packaged WinUI test application because it is required to register and activate the test host; set it to `false` only when a custom launcher owns activation. In NativeAOT mode, profiles enable only TrxReport and CodeCoverage.
Set an individual `Enable*` property to `false` to remove an extension supplied by a ClassicEngine profile, or to `true` to opt into an extension independently. CtrfReport and JUnitReport are experimental opt-ins; OpenTelemetry is also opt-in. None are enabled by any profile. `EnableMicrosoftTestingExtensionsPackagedApp` is independent of profiles and defaults to `true` for packaged WinUI and UWP test applications because it is required to register and activate the test host; set it to `false` only when a custom launcher owns activation. In NativeAOT mode, profiles enable only TrxReport and CodeCoverage.

| Property | `Default` | `AllMicrosoft` | `None` | NativeAOT | VSTest |
| --- | --- | --- | --- | --- | --- |
Expand All @@ -332,7 +332,7 @@ Set an individual `Enable*` property to `false` to remove an extension supplied
| `EnableMicrosoftTestingExtensionsCtrfReport` | Off | Off | Off | Not available | Build error |
| `EnableMicrosoftTestingExtensionsJUnitReport` | Off | Off | Off | Not added; emits unsupported warning | Build error |
| `EnableMicrosoftTestingExtensionsOpenTelemetry` | Off | Off | Off | Not available | Build error |
| `EnableMicrosoftTestingExtensionsPackagedApp` | Packaged WinUI only | Packaged WinUI only | Packaged WinUI only | Packaged WinUI only | Build error |
| `EnableMicrosoftTestingExtensionsPackagedApp` | Packaged WinUI/UWP | Packaged WinUI/UWP | Packaged WinUI/UWP | Packaged WinUI/UWP | Build error |
| `EnableAspireTesting` | Off | Off | Off | Build error | Supported |
| `EnablePlaywright` | Off | Off | Off | Build error | Supported |

Expand All @@ -346,7 +346,7 @@ Individual extension toggles remain unset and disabled when a profile does not e
| `EnableMicrosoftTestingPlatform` | Advanced version-alignment escape hatch. When `true` for an `IsTestApplication=true` ClassicEngine or NativeAOT project, adds an explicit `Microsoft.Testing.Platform` package reference using `MicrosoftTestingPlatformVersion`. It is ignored for test libraries and VSTest. It is normally unnecessary and does not select the runner or change `IsTestingPlatformApplication`. |
| `EnableMSTestSourceGeneration` | Adds `MSTest.SourceGeneration` to non-NativeAOT projects. For reusable test libraries, it also adds `MSTest.TestAdapter`, which provides the runtime hooks referenced by generated code. .NET Standard is not supported because the adapter does not ship compatible runtime hooks. NativeAOT projects always include source generation. |
| `MSTestVersion` | Overrides the versions of the MSTest framework, adapter, and source generator supplied by the SDK. |
| `MicrosoftTestingExtensionsPackagedAppVersion` | Overrides the packaged-app launcher version supplied to packaged WinUI MTP projects. |
| `MicrosoftTestingExtensionsPackagedAppVersion` | Overrides the packaged-app launcher version supplied to packaged WinUI and UWP MTP projects. |

`EnableMSTestRunner` is set by MSTest.Sdk and should not normally be set by projects. Component-specific properties such as `MicrosoftTestingPlatformVersion`, `MicrosoftTestingExtensionsCommonVersion`, and the individual `MicrosoftTestingExtensions*Version` properties are advanced version-alignment controls.

Expand Down Expand Up @@ -398,7 +398,7 @@ An experimental MTP extension (`Microsoft.Testing.Extensions.Logging`, `[TPEXP]`

### Microsoft.Testing.Extensions.PackagedApp

An MTP extension (`Microsoft.Testing.Extensions.PackagedApp`) that enables testing packaged Windows apps by registering the layout with the `PackageManager` and activating it by AUMID through the [ITestHostLauncher](#itesthostlauncher) extension point, rather than a plain `Process.Start`. `packagedClassicApp`/`win32App` hosts receive normal `argv` (including classic AppContainer hosts); `windowsApp`/UWP hosts call `PackagedAppExtensions.GetTestApplicationArguments(LaunchActivatedEventArgs.Arguments)` before creating the MTP builder to restore the same logical arguments. For a selected AppContainer application, the launcher also contributes its exact package SID through `ITestHostControllerConnectionAuthorizer`, and the platform grants only the minimum controller-pipe client rights. Register via `builder.AddPackagedAppDeployment()`, or simply by referencing the package (its MSBuild props register the hook). The launcher only enables itself when the test application is a packaged layout — a manifest in the app's own directory, or an ancestor `AppxManifest.xml` whose `Application/@Executable` resolves back to the app directory — so referencing it from an **unpackaged** app does not force the test host controller process model or copy the build output; `TESTINGPLATFORM_PACKAGEDAPP_LAUNCHER` (`auto`/`always`/`never`) overrides that decision. These communication primitives do not change the current SDK/platform routing limitation: true UWP/AppContainer projects are still selected for VSTest rather than started as MTP test hosts. Introduced in [PR #9454](https://github.com/microsoft/testfx/pull/9454); AUMID activation added in [PR #9970](https://github.com/microsoft/testfx/pull/9970). See also [ITestHostLauncher](#itesthostlauncher) and [docs/winui-testing.md](winui-testing.md).
An MTP extension (`Microsoft.Testing.Extensions.PackagedApp`) that enables testing packaged Windows apps by registering the layout with the `PackageManager` and activating it by AUMID through the [ITestHostLauncher](#itesthostlauncher) extension point, rather than a plain `Process.Start`. `packagedClassicApp`/`win32App` hosts receive normal `argv` (including classic AppContainer hosts); `windowsApp`/UWP hosts call `PackagedAppExtensions.GetTestApplicationArguments(LaunchActivatedEventArgs.Arguments)` before creating the MTP builder to restore the same logical arguments. For a selected AppContainer application, the launcher also contributes its exact package SID through `ITestHostControllerConnectionAuthorizer`, and the platform grants only the minimum controller-pipe client rights. Register via `builder.AddPackagedAppDeployment()`, or simply by referencing the package (its MSBuild props register the hook). The launcher only enables itself when the test application is a packaged layout — a manifest in the app's own directory, or an ancestor `AppxManifest.xml` whose `Application/@Executable` resolves back to the app directory — so referencing it from an **unpackaged** app does not force the test host controller process model or copy the build output; `TESTINGPLATFORM_PACKAGEDAPP_LAUNCHER` (`auto`/`always`/`never`) overrides that decision. MSTest.Sdk uses a full-trust sidecar controller to apply this path to classic UWP, modern UWP, packaged WinUI, and AppContainer-configured WinUI without VSTest. Introduced in [PR #9454](https://github.com/microsoft/testfx/pull/9454); AUMID activation added in [PR #9970](https://github.com/microsoft/testfx/pull/9970). See also [ITestHostLauncher](#itesthostlauncher) and [docs/winui-testing.md](winui-testing.md).

## N

Expand Down
20 changes: 10 additions & 10 deletions docs/winui-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

| Application model | Recommended test configuration | Test host |
| --- | --- | --- |
| Legacy UWP (`uap10.0`) | Existing non-SDK project with `MSTest.TestAdapter` and `MSTest.TestFramework` | VSTest AppContainer |
| Modern UWP (.NET 9+, `UseUwp`) | `MSTest.Sdk` | VSTest AppContainer, selected automatically |
| Packaged full-trust WinUI 3 (`UseWinUI`) | `MSTest.Sdk` | MTP with automatic package registration and AUMID activation |
| Legacy UWP (`uap10.0`) | Existing project importing `MSTest.Sdk` | MTP sidecar controller with native UAP adapter assets |
| Modern UWP (.NET 9+, `UseUwp`) | `MSTest.Sdk` | MTP sidecar controller with AUMID activation |
| Packaged full-trust WinUI 3 (`UseWinUI`) | `MSTest.Sdk` | MTP sidecar controller with automatic package registration and AUMID activation |
| Unpackaged WinUI 3 (`UseWinUI`, `WindowsPackageType=None`) | `MSTest.Sdk` | MTP direct executable launch |
| AppContainer-configured WinUI 3 | VSTest | MTP is not currently supported |
| WinUI 3 `packagedClassicApp` with `TrustLevel="appContainer"` | `MSTest.Sdk` | MTP sidecar controller with exact package-SID pipe authorization |

True UWP/AppContainer test hosts cannot use MTP. `MSTest.Sdk` therefore selects VSTest when `UseUwp=true` and reports a build error if a project explicitly selects MTP for that application model. Legacy `uap10.0` projects remain on their existing package-based setup because they do not use the SDK-style project system.
`MSTest.Sdk` uses Microsoft.Testing.Platform for all of these models. Packaged and AppContainer applications are not executed as the initial tool process: MSBuild starts an ordinary full-trust sidecar controller, which keeps ownership of command-line preparation, cancellation, reports, retries, and exit-code reconciliation while `Microsoft.Testing.Extensions.PackagedApp` registers and activates the selected manifest application. No `Microsoft.NET.Test.Sdk`, `vstest.console`, `UwpTestHostRuntimeProvider`, or Visual Studio deployment runtime is involved.

### Packaging and sandboxing are separate choices

Expand All @@ -21,7 +21,7 @@ Two independent settings describe a Windows app:

A packaged WinUI 3 desktop app is full trust by default. Packaging gives it identity and MSIX file/registry virtualization, but does not put it in AppContainer. A WinUI 3 app can be explicitly configured for AppContainer with `uap10:TrustLevel="appContainer"` in its package manifest; it then has the same MTP communication restrictions as UWP.

`Microsoft.Testing.Extensions.PackagedApp` currently supports packaged **full-trust** desktop hosts end to end. It also provides both communication primitives an AppContainer host needs: a reusable launch-activation argument bootstrap and exact package-SID authorization on the controller pipe. Those primitives do not by themselves make true UWP/AppContainer an MTP test-host mode: `MSTest.Sdk` still routes `UseUwp=true` to VSTest and rejects forced MTP, and the existing MTP startup path still expects an ordinary initial controller process.
`Microsoft.Testing.Extensions.PackagedApp` supports both full-trust and AppContainer hosts end to end. `MSTest.Sdk` supplies the full-trust sidecar controller, selects the packaged test executable explicitly, and ships the UAP-compatible bootstrap and adapter assets needed by classic UWP.

#### AppContainer communication primitives

Expand All @@ -30,7 +30,7 @@ MTP's controller must give the new test host its command-line options and then e
1. **Activation arguments are not process arguments.** For a packaged full-trust desktop app, AUMID activation starts an ordinary Win32 process and the activation string becomes its command line, which .NET exposes through `Environment.GetCommandLineArgs()`. A true UWP/AppContainer app instead receives one opaque string through [`LaunchActivatedEventArgs.Arguments`](https://learn.microsoft.com/uwp/api/windows.applicationmodel.activation.launchactivatedeventargs.arguments) in `Application.OnLaunched`. `PackagedAppExtensions.GetTestApplicationArguments(args.Arguments)` restores that value to the `string[]` expected by the platform before `TestApplication.CreateBuilderAsync`.
2. **The controller pipe must authorize the app identity.** MTP normally creates its named pipe with [`PipeOptions.CurrentUserOnly`](https://learn.microsoft.com/dotnet/api/system.io.pipes.pipeoptions), granting the creating token's owner SID access. An AppContainer token is additionally restricted by its package SID, and Windows grants access only when both the normal and restricted identity checks succeed. The packaged-app launcher now contributes the selected application's exact package SID; the platform grants only the minimum client rights and explicitly rejects `ALL APPLICATION PACKAGES`.

The packaged-app handshake transfers the controller pipe name and related environment values through the package's `LocalState`. Together these mechanisms solve activation argument delivery and pipe access. The remaining limitation is earlier in the lifecycle: selecting and starting a true UWP/AppContainer application as an MTP test host is not yet supported by the SDK/platform routing described above.
The packaged-app handshake transfers the controller pipe name and related environment values through the package's `LocalState`. Result, diagnostic, TRX, HangDump, and Retry artifacts are written to package-owned scratch storage and recovered to the controller-visible results directory after the sandboxed host exits.

For modern UWP, the test-related part of the project is reduced to the SDK declaration:

Expand All @@ -44,7 +44,7 @@ For modern UWP, the test-related part of the project is reduced to the SDK decla
</Project>
```

The UWP XAML, MSIX, architecture, and Native AOT settings remain application concerns. Modern UWP builds also continue to require the Visual Studio MSBuild toolchain.
The UWP XAML, MSIX, architecture, and Native AOT settings remain application concerns. Modern and classic UWP builds continue to require the Visual Studio MSBuild/UWP toolchain, but not its VSTest runtime provider.

## WinUI 3

Expand Down Expand Up @@ -191,7 +191,7 @@ Notable properties:
- Nothing changes for a packaged **full-trust** desktop host, an unpackaged app, an ordinary console test app, or any non-Windows run: the pipe is created exactly as it was before.
- No loopback exemption (`CheckNetIsolation LoopbackExempt`) is used or needed — that applies to network sockets, not named pipes.

> **Elevated controllers are out of scope.** The pipe is owned by the creating token's *owner* SID, which for an elevated controller is `BUILTIN\Administrators`. An AppContainer can never be elevated, so its own owner SID is the user — and the client-side `PipeOptions.CurrentUserOnly` check then rejects the connection as "not owned by the current user" even though the DACL admits it. Run AppContainer test hosts from a non-elevated controller.
> **Run AppContainer tests non-elevated.** The exact package-SID grant and normal-user controller path are covered end to end. Elevation changes the controller token owner and integrity boundary and is not a supported AppContainer test configuration.

Set `TESTINGPLATFORM_PACKAGEDAPP_PIPEAUTHORIZATION` to override the decision. Values are compared case-insensitively; anything unrecognized falls back to `auto`.

Expand All @@ -211,7 +211,7 @@ The launcher therefore decides for itself, per run:
| --- | --- | --- |
| Not Windows | no | Nothing changes. Packaged Windows apps are a Windows-only concept. |
| Supported packaged full-trust layout (an `AppxManifest.xml` that describes this app — see below) | yes | The layout is registered and activated by AUMID. |
| True UWP/AppContainer packaged layout | yes, but unsupported | Registration, activation arguments, and exact package-SID pipe authorization are implemented; SDK/platform routing still does not support starting it as an MTP test host. |
| UWP or AppContainer packaged layout | yes | The sidecar controller activates the exact manifest application and authorizes only its package SID on controller and extension pipes. |
| Any other layout — including unpackaged WinUI and ordinary console test apps | no | The platform keeps its default in-process / `Process.Start` path. |

So an **unpackaged** WinUI app that references `Microsoft.Testing.Extensions.PackagedApp` (directly, or transitively through a shared `Directory.Packages.props`) pays nothing for it: no extra process, and no copy of the build output into a deployment directory.
Expand Down
4 changes: 2 additions & 2 deletions eng/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function Unzip {
function Confirm-NugetPackages {
Write-Verbose "Starting Confirm-NugetPackages."
$expectedNumOfFiles = @{
"MSTest.Sdk" = 15
"MSTest.Sdk" = 371
"MSTest.TestFramework" = 105
"MSTest.TestAdapter" = 68
"MSTest.TestAdapter" = 75
"MSTest" = 10
"MSTest.Analyzers" = 56
"MSTest.SourceGeneration" = 8
Expand Down
Loading
Loading