Skip to content

[rel/4.5] Backport packaged-app SDK environment isolation - #11854

Merged
Amaury Levé (Evangelink) merged 2 commits into
rel/4.5from
dev/amauryleve/packaged-sdk-servicing
Oct 9, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
rel/4.5from
dev/amauryleve/packaged-sdk-servicing

Conversation

@Evangelink

@Evangelink Amaury Levé (Evangelink) commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Backport merged #11828 (26c2897b0c7f53f35337427b881019df3e8a42ae) to rel/4.5, based on 423f76885c25eb92da6699599bc66d3223e611e2. Servicing versions remain MSTest 4.5.2 / Microsoft.Testing.Platform 2.5.2. This is a draft for servicing review; nothing is merged and the original PR branch is untouched.

Scope

  • Align nested SDK10 consumers' MSBuildSDKsPath, MSBuildExtensionsPath, and x64 runtime root with the selected CLI while preserving shared NuGet, tooling, and diagnostic settings. Wire native MSTest and WinUI consumers to the shared acceptance helper; scope and restore the standalone probe's environment.
  • Backport missing/conflicting inherited-SDK guards, actual build provenance, ANSI SGR/reset-only normalization, bounded host JSON parsing, and the sidecar Usage negative assertion. Force DOTNET_CLI_CONTEXT_VERBOSE=1 in native child tests. Preserve result/exit, selection, handshake/no-handshake, retry, launch-profile, and cleanup assertions.
  • Resolve committed conflicts in the directly coupled servicing controller/runtime, targets, and tests. Preserve project-local bootstrap/staging and incremental cleanup, legacy-prefix parser compatibility, case-insensitive informational/response-file routing, and ;mstest filter registration. Retained native scenarios use the existing guarded cleanup helper.
  • Repair app-model pipeline conflicts without changing its category/native-class selector, SDK10 environment, actions, diagnostics, or failure behavior.
  • Repair the coupled malformed neutral resource and generated catalogs: remove the duplicate neutral value, recover known-valid translated inputs from c6e36dd11^, and regenerate with the owning UpdateXlf target. Final diffs only remove one duplicate source/target pair in each of 13 catalogs; no translations were hand-edited.
  • Remove obsolete merge variants from the shipped PackagedApp PACKAGE.md and its directly related WinUI guide. Both were byte-identical to the servicing base and caused first-head CI markdownlint failures; preserve the existing bootstrap/launch-profile/informational documentation. No optional headings are added.
  • Update sample contributor validation to use the repository-pinned outer dotnet test and project-selected servicing TFM. Public sample package pins are unchanged. No absent VSTestBridge test fix, acceptance-guidance framework, or unrelated main features are imported.

Commits: 7cc5ed6d998f1f4235691b4d9b04d8843d6c5642 implements the backport and coupled build prerequisites; 08dcedb19ef5780b3206a47a0b5ebeab7fe54c68 removes only the coupled documentation merge artifacts.

Local validation — final refreshed shipping layout

Fresh full Release build/pack from this isolated servicing checkout; no main-checkout or other-worktree shipping outputs were reused. The toolchain is SDK 12.0.100-alpha.1.26480.103. Acceptance projects target net11.0 and ran on its bundled runtime with DOTNET_ROLL_FORWARD=Major. Real nested consumers use SDK 10.0.401 and aligned locally packed 4.5.2-dev / 2.5.2-dev packages. Acceptance fixtures use unique per-run NuGet caches and this checkout's configuration-matched local package feeds.

The complete composed validation was repeated after repacking the repaired shipping readme:

# Owning-project catalog regeneration after recovery of valid translated inputs.
.\.dotnet\dotnet.exe msbuild src\Platform\Microsoft.Testing.Extensions.PackagedApp\Microsoft.Testing.Extensions.PackagedApp.csproj -t:UpdateXlf -p:TargetFramework=net8.0 -p:Configuration=Release -bl:artifacts\log\Release\servicing-update-xlf-3.binlog -v:minimal
# PASSED: all 13 catalogs have one matching neutral source per resource;
# source/target placeholders preserved.

.\build.cmd -pack -c Release -bl
# PASSED after prerequisite repairs, and PASSED again for final refreshed packages:
# 81 projects, 0 warnings, 0 errors, package content/metadata validation passed.
# 33 fresh packages, including classic UAP assets. Final packaged PACKAGE.md
# exactly matches its repaired source.

$env:DOTNET_ROLL_FORWARD = 'Major'
$env:DOTNET_CLI_CONTEXT_VERBOSE = '1'
$env:TESTFX_RUN_WINDOWS_APP_MODEL_TESTS = '1'
$env:TESTFX_DOTNET_10_PATH = 'C:\Program Files\dotnet\dotnet.exe'

.\.dotnet\dotnet.exe test --project test\IntegrationTests\MSTest.Acceptance.IntegrationTests\MSTest.Acceptance.IntegrationTests.csproj -c Release --no-build -p:UsingDotNetTest=true -p:ArtifactsTestResultsDir=artifacts\TestResults\Release\ServicingFinal\MSTest --filter 'FullyQualifiedName~PackagedAppNativeDotnetTestTests|FullyQualifiedName~PackagedAppIntegrationTests|FullyQualifiedName~WindowsApplicationModelPackageTests' -bl:artifacts\log\Release\servicing-final-mstest.binlog --show-test-results failed
# PASSED, exit 0: 123/123, zero skips, 2m 01s.
# 40 native cases (39 process scenarios + normalization guard),
# 73 packed-consumer cases, and 10 package/SDK contracts including both SDK guards.

.\.dotnet\dotnet.exe test --project test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj -c Release --no-build -p:UsingDotNetTest=true -p:ArtifactsTestResultsDir=artifacts\TestResults\Release\ServicingFinal\WinUI --filter 'FullyQualifiedName~PackagedFullTrustWinUI_NativeDotnetTestPreservesExecutionIdAndPublishesResults|FullyQualifiedName~PublicPackagedWinUISample' -bl:artifacts\log\Release\servicing-final-winui.binlog --show-test-results failed
# PASSED, exit 0: 6/6 actual WinUI/public-sample checks, zero skips, 7m 44s.
# Includes the actual standalone probe with conflicting inherited SDK/runtime paths.

.\.dotnet\dotnet.exe test --project test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj -c Release -f net8.0 --no-build -p:UsingDotNetTest=true -p:ArtifactsTestResultsDir=artifacts\TestResults\Release\ServicingFinal\Unit --filter 'FullyQualifiedName~PackagedApp' -bl:artifacts\log\Release\servicing-final-unit.binlog --show-test-results failed
# PASSED, exit 0: 174 passed, 2 existing non-Windows-only skips, 0 failures, 8s.
# All 40 argument/bootstrap/transport/response-file tests and filter provider passed.

npx --no-install markdownlint-cli2 '**/*.md'
# PASSED: repository-wide markdown gate, 0 errors.

Independent same-built-host JSON discovery was reconciled by exact UID against final TRX: 305 discovered/results, 303 passed, two existing non-Windows-only unit skips, no missing/extra IDs. Independently source-planned native method/data-row counts match all 40 discovered/executed cases. All 129 acceptance cases passed without skips. The two unit skips are OnNonWindows_AuthorizesNothingEvenWithAlwaysMode and IsEnabledAsync_OnNonWindows_IsDisabledEvenForAPackagedLayoutAndAlwaysMode.

Coverage includes selected-work/failure/zero-result, help/discovery/JSON/response-file, no-build/named-profile precedence, staging/clean, suppressed/incompatible launcher, custom executable, cancellation, multi-TFM exit aggregation, and MSTest-only filter-registration contracts. SDK provenance assertions check the SDK version plus actual MSBuild tools/extensions/SDK directories, not merely dotnet --version.

The standalone probe intentionally exits 1 for its existing coverage/composition boundary. Its actual 14-entry report was checked: 4 Verified (filter-trx, hangdump, packagedapp, retry), 1 Partial (coverage succeeds but has zero covered sample lines), 6 Unavailable, 3 NotExercised. Unsupported extensions are not claimed to execute successfully.

Additional checks passed: pipeline YAML parse plus retained selector/SDK10 environment assertions, targets XML, PowerShell probe syntax, C# UTF-8 BOM preservation, catalog source/placeholder correspondence, and git diff --check.

Evidence and limitations

  • Final TRX/JUnit/CTRF/coverage: artifacts\TestResults\Release\ServicingFinal\{MSTest,WinUI,Unit}; binlogs use the exact paths above. Actual WinUI/probe evidence remains under artifacts\log\Release\PackagedWinUI\...\extension-probes.
  • Local session artifacts retain initial failing evidence, exact console logs, discovery inventories, final UID reconciliation, and SHA256 manifests of all 33 final packages. Final example hashes: MSTest.Sdk.4.5.2-dev.nupkg = c1db16d8bef9595dfbf4787c009314a749c231dcaa6d893931462cb395589694; Microsoft.Testing.Extensions.PackagedApp.MSBuild.2.5.2-dev.nupkg = d148ef14ceeb864518deb05a282fc38ecd26cacd7f2898682d65175e4a2fd73c.
  • Initial full pack failed on committed malformed catalogs and missing cleanup calls, repaired above. Initial outer discovery/validation commands also failed (SDK12 JSON discovery and duplicate CLI results-directory arguments); those attempts are not counted as proof. Independent host discovery and repository-standard ArtifactsTestResultsDir produced passing, exactly reconciled executions. No checks or diagnostics were disabled.
  • Classic/modern UWP runtime execution, WinApp CLI interoperability, external-service publishing, and unrelated acceptance suites were not selected. Classic UAP packing/package-layout contracts, native WinUI activation, actual sample source builds, local result publication, and owned registration cleanup were exercised.

Remote CI status

Head 08dcedb19ef5780b3206a47a0b5ebeab7fe54c68 is pushed and this draft's head/base/body were read back. First-head lint's nine inherited merge-artifact errors were addressed by the second commit. New-head GitHub markdownlint, source BOM, and CLA checks passed. Azure build 1629394 is queued/not started at the latest inspection; remote build/app-model CI is not yet verified. A same-session follow-up is scheduled to retain servicing ownership through that result. This PR is not claimed merge-ready from local results alone.

Backport #11828 and resolve directly coupled servicing merge artifacts while preserving bootstrap, launch-profile, filter and cleanup contracts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5cb3e91b-2f12-40f1-b862-e1ddb398b7e5
Preserve the serviced bootstrap, launch-profile and informational-response documentation; remove obsolete merge variants responsible for new-head markdownlint failures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5cb3e91b-2f12-40f1-b862-e1ddb398b7e5
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review October 9, 2026 08:27
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) October 9, 2026 08:27
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 9, 2026

@github-actions github-actions Bot 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.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Summary

Reviewed the full diff (28 files, docs/pipeline/MSBuild targets/C#/tests/localization) for this rel/4.5 backport of #11828. This PR is almost entirely git-conflict cleanup (resolving <<<<<<</=======/>>>>>>> markers left by a prior merge) plus a genuine new feature: aligning a nested SDK's MSBuildSDKsPath/MSBuildExtensionsPath/DOTNET_ROOT_X64/etc. with the CLI actually invoked, so a parent dotnet test's exported SDK environment can't leak into native/packaged-app child processes.

What I checked

  • Conflict-marker hygiene (all 28 files in the diff): every file touched by this PR resolves cleanly — no stray <<<<<<</=======/>>>>>>> remain in docs/winui-testing.md, the pipeline YAML, Program.cs, PackagedAppControllerArguments.cs, the MSBuild .targets, PACKAGE.md, the .resx/.xlf catalogs, or the test files.
  • Localization (ExtensionResources.resx + 13 .xlf catalogs): the diff correctly removes a duplicated/stray <value>/<source>/<target> pair for PackagedAppControllerNativeLauncherDisabled left over from the merge conflict; the retained single entry matches the current (non-"Native"-prefixed) message and all locked tokens remain intact. Clean.
  • PackagedAppControllerArguments.Configure: the resolved version keeps the CommandLineParser.Parse(...).IsOptionSet(...) case-insensitive matching (verified ParseResult.IsOptionSet uses StringComparison.OrdinalIgnoreCase and trims -/-- prefixes), so the "Match native informational switches case-insensitively" behavior from the conflicting branch is preserved without manual casing logic. Unit tests (Configure_HelpAndDiscoverySelectActualHostWithOrWithoutNativeTransport) cover -?, --?, --help, --list-tests, -list-tests.
  • MSBuild .targets: _ConfigureTestingPlatformPackagedAppRunArguments now depends on _PrepareTestingPlatformPackagedAppRunController (project-local staged controller) rather than the old _ConfigureTestingPlatformPackagedAppEnvironment/inline-prefix approach, consistent with the new bootstrap-file design; RunCommand/RunArguments wiring and the new _PrepareTestingPlatformPackagedAppRunController / _RecordTestingPlatformPackagedAppRunControllerFiles targets resolve consistently with Program.cs's bootstrap-file reading logic.
  • ConfigureDotnetSdkEnvironment (new helper in AcceptanceTestBase.cs): correctly derives dotnetRoot/sdkDirectory from the passed dotnetPath/sdkVersion, sets MSBuildSDKsPath, MSBuildExtensionsPath, DOTNET_ROOT, DOTNET_ROOT_X64, DOTNET_INSTALL_DIR, DOTNET_MULTILEVEL_LOOKUP=0, MSBUILDUSESERVER=0. Covered by a dedicated data-driven unit test (NativeSdkEnvironment_AlignsSdkPathsAndPreservesSharedTooling) that verifies both the "clean environment" and "inherited conflicting SDK" cases, and preserves unrelated keys like NUGET_PACKAGES/MSBUILDLOGIMPORTS. Good regression coverage.
  • PackagedWinUITests.cs probe-environment regression test: deliberately seeds probeEnvironment with wrong "parent-sdk"/"parent-dotnet" paths so the standalone Probe-Extensions.ps1 script must self-correct them — a solid test for the isolation fix working independent of the C#-side helper.
  • Probe-Extensions.ps1: saves/restores previous env-var values in a finally block (no permanent mutation of the parent shell), matching the README's claim "without changing the parent shell's environment or the shared NuGet cache."
  • Test asset lifecycle: GenerateAssetAsync's callers switched from using TestAsset asset = ... to a bare TestAsset asset = ... passed into WindowsApplicationModelTestTools.ExecuteWithPackageCleanupAsync(asset, identity, action). Verified ExecuteWithPackageCleanupAsync itself calls testAsset.Dispose() on success internally, so disposal is not dropped — just relocated. No double-dispose or leak.
  • ANSI/duration normalization (NormalizeConsoleOutput): strips \u001b\[[0-9;]*m SGR sequences and blank lines from captured native-process output before assertions — reasonable and consistent with the "ANSI SGR/reset-only normalization" scope item, and doesn't hardcode any \d+ms duration pattern.
  • JSON extraction in DotnetRun_HelpAndDiscoveryDescribeActualHost: now locates {...} boundaries in --list-tests json output before JsonDocument.Parse, guarding against leading diagnostic noise (e.g., from DOTNET_CLI_CONTEXT_VERBOSE=1) that would otherwise break JSON parsing. Assert.IsGreaterThanOrEqualTo(0, jsonStart, ...) and Assert.IsGreaterThan(jsonStart, jsonEnd, ...) read a little unusually (first two args are lowerBound, value per Assert.IsGreaterThan<T>(T lowerBound, T value, ...)), but the logic is correct: it asserts jsonStart >= 0 and jsonEnd > jsonStart.

Pre-existing issue found, out of this PR's scope (FYI only — no action requested)

src/Platform/Microsoft.Testing.Extensions.PackagedApp/InternalAPI/InternalAPI.Unshipped.txt still contains unresolved <<<<<<</=======/>>>>>>> git conflict markers on this PR's base and head (confirmed identical on rel/4.5 and on this PR's head commit 08dcedb). This file is not part of this PR's diff, so it predates these commits and was already broken on rel/4.5 before this backport. Since PublicAPI/InternalAPI analyzers typically fail the build on malformed entries, this will likely break CI for this and any other PR touching Microsoft.Testing.Extensions.PackagedApp on rel/4.5 until fixed in a separate, focused commit (resolving to the IsInformationalRequest/BootstrapFileName/4-arg Configure overload shape that matches the already-resolved PackagedAppControllerArguments.cs in this PR). Flagging since it's directly adjacent to files this PR edits and will surface in the queued CI run mentioned in the PR description.

Verdict

No actionable findings within this PR's diff. The conflict resolution appears complete and self-consistent across the MSBuild targets/Program.cs/tests, the SDK-isolation fix is well-tested on both the acceptance and unit-test level, and localization catalogs are correctly de-duplicated. No inline comments were posted.

@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 9, 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 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Final test-triage resolution — Azure Pipelines build 1629411

Analysis is final (completed aggregate build; evidenceIncomplete: false).

Summary: Build microsoft.testfx succeeded. Out of 108,624 normalized test records across all build legs, 6 are recorded as failed, 0 timeline signals, 0 diagnostics, and 0 slow-duration regressions were found.

All 6 failed records are self-fail-then-pass retry-mechanism probe tests, by design, not product defects:

  • WinUIMtpPackagedApp.UnitTest1.RetryFailsFirstAttempt — comment in source states: "This probe deliberately fails the first retry attempt and passes the next one." First TRX attempt fails, retry attempt passes.
  • PackagedWinUI.PackagedWinUITestCases.RetryTestMethod_PassesOnSecondAppContainerHost — asserts "The first AppContainer host fails so Retry must activate a second host"; first attempt fails, second attempt (new AppContainer host) passes.
  • NativeTests.Outcome (4 occurrences across different native-sidecar test-suite runs) — asserts expected host failure; each failing attempt is paired with an immediately following passing retry attempt in the same Retries/<id>/ folder structure.

Each failure is matched by a passing retry attempt for the identical test name/sourceFile family, confirming intended fail-then-pass probe behavior rather than flakiness or a regression. These are part of the retry-extension validation samples (samples/public/WinUIMtpPackagedApp, test/IntegrationTests/.../PackagedAppNativeDotnetTestTests.cs, PackagedWinUITests.cs).

Conclusion: No actionable test-product failure, crash/hang, or duration regression found for this build. No issue created — per playbook, intentional-by-design probe outcomes don't meet the durable-defect threshold, and there is no earlier preliminary comment on this PR to supersede with a downgrade.

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

@Evangelink

Copy link
Copy Markdown
Member Author

Servicing CI verification completed for head 08dcedb19ef5780b3206a47a0b5ebeab7fe54c68.

Azure build 1629411 completed successfully against this PR's merge SHA 504fc57f4816cb9fa33b83203219cb2d648df9c6. Windows Release, Windows Debug, Linux Release, WindowsSamples Release, and Windows application-model acceptance all passed. GitHub lint, BOM and CLA checks also passed.

The actual application-model logs were read, not inferred from job status:

Check Result Evidence
Package contracts and inherited SDK guards 10 passed, 0 skipped Azure log 60
Native packaged routing plus classic/modern UWP 53 passed, 0 skipped Azure log 84
WinUI, public sample/probe and WinApp CLI interoperability 12 passed, 0 skipped Azure log 93
Owned package cleanup Passed Azure log 96

Application-model job logs

This supplements the local fresh-pack evidence in the PR description: 305 exact discovery/result matches, 303 passed and two existing non-Windows-only unit skips, including all 129 acceptance cases passing. Remote CI also exercised the classic/modern UWP runtime and WinApp CLI scenarios that were not selected locally. Intentional first-attempt retry failures remain expected probe artifacts; they are not hidden or reclassified as product success.

Implementation commit: 7cc5ed6d998f1f4235691b4d9b04d8843d6c5642; coupled documentation repair: 08dcedb19ef5780b3206a47a0b5ebeab7fe54c68. No merge or readiness change was performed by this owner. Scheduled CI follow-up is now complete.

@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 9, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 91fb070 into rel/4.5 Oct 9, 2026
47 of 48 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/packaged-sdk-servicing branch October 9, 2026 10:21
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the state/needs-review Awaiting review from the team. label Oct 9, 2026
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.

2 participants