Skip to content

Preserve host-injected ProjectData targets on .NET 11 - #56522

Merged
baronfel merged 2 commits into
release/11.0.1xxfrom
rmarinho-net-11-projectdata-backport
Oct 7, 2026
Merged

baronfel merged 2 commits into
release/11.0.1xxfrom
rmarinho-net-11-projectdata-backport

Conversation

@rmarinho

@rmarinho rmarinho commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Description

Backport the same complete ProjectData host-writer precedence fix and regression tests as #56516 onto release/11.0.1xx. The SDK target and both regression-test files are byte-for-byte identical to the main PR at 5620c74ab8e3d24b392fe1329bc8ed2e88cab38e; this is not a functional subset. It is a separate release-based PR, without unrelated main-branch changes.

The final SDK-bundled ProjectData import now requires _ProjectDataTaskAssembly to be empty as well as the bundled targets to exist. This preserves the target definitions and task-assembly identity of a host writer injected through CustomAfterMicrosoftCommonTargets or CustomAfterMicrosoftCommonCrossTargetingTargets. Standalone SDK builds still import the bundled writer when no host writer is present.

Includes the same three host-injection regressions: single TFM, multi-TFM outer evaluation, and multi-TFM inner evaluation. The four existing standalone emission controls remain unchanged. Only the three product/test files are changed; no documentation changes are included. The reviewer-requested architecture-file removal is a separate docs-only commit. No version, dependency, localization, CI, or packaging changes are included.

Customer Impact

An IDE-provided ProjectData writer can be overwritten after the common-targets hooks. In the MAUI/C# Dev Kit scenario associated with the RC2 recurrence in microsoft/vscode-dotnettools#3437, this may omit expected generated assembly platform attributes and project slices, contributing to false-positive CA1416 warnings and missing iOS/MacCatalyst platforms.

A fresh, unmodified MAUI project has now passed a Windows editor smoke test with this PR's private SDK artifact and public stable extensions: zero CA1416 diagnostics, zero errors, and zero warnings. This is a fixed-SDK smoke test, not a fixed-versus-control comparison; see the evidence and limitations below.

Regression?

Likely. The unconditional bundled import was introduced by #56243, merged September 18, 2026, and backported to .NET 11. Its later import can replace an already-injected host writer. This attribution concerns the writer-precedence regression and RC2 recurrence; the original August 24 report predates that change.

Risk

Low: the production change adds one condition to an existing import. An already-selected host writer remains authoritative; the standalone bundled fallback and the existing file-existence check are preserved. No host changes, new switches, public APIs, or dependency updates are required. CI for the preceding rebased head 2607032b2dff533fe6830fb352f1bb5609e2b873 has passed; CI for the documentation-only follow-up has not yet been verified. Windows editor smoke validation passed on the pre-rebase artifact with the same fix; a controlled comparison and Android/macOS editor validation remain outstanding.

Testing

Reviewer-requested documentation removal (2026-10-07): separate docs-only commit 7d2420fc9420ce4a67622fbfa747b0f1c44c4c43 removes only .github/memory/ARCHITECTURE.md. The SDK fix and regression tests are unchanged. No local SDK tests or large rebuild were needed for this documentation-only follow-up. CI for this new head has not yet been verified; the CI and artifact results below apply to their recorded historical heads.

Pre-removal CI passed: build 1626299 completed successfully with all 11 jobs succeeded. It validates PR head 2607032b2dff533fe6830fb352f1bb5609e2b873, using CI merge commit 52d30f70f53fcf58afc23ee2434c3caaa4d8b4d7 on refs/pull/56522/merge.

Windows MAUI editor smoke test passed (2026-10-07): full report, editor logs, exact diagnostic counts, and screenshots. Created a fresh .NET MAUI App through the extension's normal .NET: New Project... flow, restored the Windows target and full multi-target template, selected Windows / Local Machine / Unpackaged, and opened MainPage.xaml.cs. The private SDK was confirmed in project-system logs; one project loaded and none failed. The unfiltered Problems panel showed zero CA1416 diagnostics, zero errors, and zero warnings, with only informational NETSDK1057. CounterBtn.Text resolved to the actual MAUI API, and generated AssemblyInfo contained TargetPlatform and SupportedOSPlatform attributes.

Tested Windows x64 with VS Code 1.140.0, public stable C# Dev Kit 3.40.210, C# 2.160.4, MAUI extension 1.17.266, .NET Install Tool 3.2.0, SDK 11.0.100-ci, and MAUI workload/templates 11.0.0-rc.2.26472.8. The SDK artifact was from pre-rebase source head 4952264741472d505b108dce258030f9d634c89c; it does not claim editor validation of the rebased binaries. No warning suppression, application build/run, emulator/device launch, extension-development override, or application/extension source changes were used. Android and iOS/MacCatalyst editor behavior were not tested in this smoke test.

Rebase provenance (2026-10-07): rebased onto release/11.0.1xx at bd731c1e1a4d2132e93424ba15f55796e37794a0, producing pre-removal head 2607032b2dff533fe6830fb352f1bb5609e2b873. There were no conflicts, and git range-diff confirms an unchanged patch. The artifact from build 1625215, CI merge 1526b9853d68d7b566f166943979fa728294134e, source head 4952264741472d505b108dce258030f9d634c89c, and the packaged-SDK/startup/A-B setup observations below predate this rebase. CI for that pre-removal head is recorded separately above. No local SDK tests, large rebuild, artifact download, or editor comparison was rerun during the rebase.

Performed in the release worktree: inspected the final three-file diff; confirmed product/test file parity with the main fix; parsed both targets as well-formed XML; passed git diff --check; validated the conflict-free commit and clean working tree. Documentation links were checked before the reviewer-requested documentation removal.

Not run locally in the source worktree: this worktree has neither the repo-local bootstrap SDK nor a Debug/Release redist SDK layout. No local SDK build or repository tests were run, and no large local rebuild was initiated solely for PR preparation. A system or stale SDK was not used as a substitute. Validation recorded on #56516 is not claimed as fresh validation of this release backport.

Pre-rebase Windows x64 artifact: build 1625215 published Windows_x64_Assets. Download the artifact and extract dotnet-sdk-11.0.100-ci-win-x64.zip.

The archive provenance identifies CI merge 1526b9853d68d7b566f166943979fa728294134e from source head 4952264741472d505b108dce258030f9d634c89c. Its packaged SDK contains the host-precedence guard, bundled ProjectData targets, and task assembly. Archive SHA-256: 4F2F54B1FE690606518EB74ECBE5A8904ED547BCD663B716AF85C3BAAD164404.

Controlled comparison prepared, not performed: two private copies of that artifact resolve SDK 11.0.100-ci and run successfully. The fixed copy is unmodified; the control removes only the import guard. Separate workspaces have global.json pins for their respective private SDKs. Global SDK installation and user PATH were not changed.

Remaining validation: a fixed-versus-control editor comparison must establish that the control reproduces the issue and the fixed SDK removes it with the same project, workloads, and extension versions. Android and macOS/iOS/MacCatalyst editor scenarios remain unvalidated by the Windows smoke test. No additional pipeline was manually triggered.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@rmarinho

rmarinho commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

Windows MAUI editor smoke test: PASS

Validated on 2026-10-07 with the Windows x64 SDK artifact from this PR and public stable/release-channel extensions only.

Created a fresh, unmodified .NET MAUI App named ProjectDataStableSmoke through the extension's normal .NET: New Project... flow. Restored the Windows target and then the full multi-target template, allowed C# Dev Kit to complete project initialization, selected Local Machine, Unpackaged for Windows, and inspected MainPage.xaml.cs.

Result: 0 CA1416 diagnostics, 0 errors, and 0 warnings. The unfiltered Problems panel had all diagnostic severities enabled. The only workspace diagnostic was informational NETSDK1057: "You are using a preview version of .NET." Normal template usages of CounterBtn.Text and SemanticScreenReader.Announce(CounterBtn.Text) did not produce CA1416 warnings. Hovering CounterBtn.Text resolved the actual MAUI API as string Button.Text { get; set; }.

Tested configuration

Component Version / selection
Host Windows x64
VS Code 1.140.0, stable; commit 07f806f999227108933c2e30515b26eecc1fda74
C# Dev Kit 3.40.210, public stable
C# 2.160.4, public stable
.NET MAUI extension 1.17.266, public stable
.NET Install Tool 3.2.0, public stable
SDK 11.0.100-ci, exact global.json pin with roll-forward disabled
MAUI workload/templates 11.0.0-rc.2.26472.8
Active C# editor context net11.0-windows10.0.19041.0
Active launch TFM net11.0-windows10.0.19041.0, Local Machine / Unpackaged
Project initialization 1 loaded, 0 failed
Windows restore / full-template restore Both succeeded; editor restore also completed successfully

The extension versions were checked against Marketplace channel metadata and Developer: Show Running Extensions. The profile was isolated, auto-update was disabled, and no --extensionDevelopmentPath override was used. This replaces the earlier attempt with internal Dev Kit 11.0.2, which was not release-channel validation.

SDK and editor provenance

Used CI build 1625215, artifact Windows_x64_Assets, archive dotnet-sdk-11.0.100-ci-win-x64.zip.

  • PR head tested: 4952264741472d505b108dce258030f9d634c89c (still the current head when posting).
  • SDK/CI merge commit: 1526b9853d68d7b566f166943979fa728294134e.
  • Archive SHA-256: 4F2F54B1FE690606518EB74ECBE5A8904ED547BCD663B716AF85C3BAAD164404.

Paths below abbreviate the private extracted net11-build-1625215 directory as <lab>:

SDK executable: <lab>\dotnet\dotnet.exe
Project: <lab>\fixed\ProjectDataStableSmoke\ProjectDataStableSmoke.csproj

Editor log excerpts:
Found installed dotnet location "<lab>\dotnet\dotnet.exe" to load projects.
Project Host Dotnet Root: <lab>\dotnet
Dotnet path: <lab>\dotnet\dotnet.exe
Completed: command: "<lab>\dotnet\dotnet.exe" restore <lab>\fixed\ProjectDataStableSmoke.slnx --interactive --nodereuse:false
Completed: Restoring NuGet packages
Project system initialization finished. 1 project(s) are loaded, and 0 failed to load.

This confirms the private SDK was used by the editor/project system, not merely by an integrated terminal. The Windows design-time AssemblyInfo.cs contained:

[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows10.0.19041.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows10.0.17763.0")]

Diagnostic evidence

{
  "file": "MainPage.xaml.cs",
  "targetFramework": "net11.0-windows10.0.19041.0",
  "ca1416Count": 0,
  "ca1416Diagnostics": [],
  "errors": 0,
  "warnings": 0,
  "workspaceInfoCount": 1,
  "workspaceInfoCode": "NETSDK1057",
  "loadedProjects": 1,
  "failedProjects": 0
}

MainPage.xaml.cs and the unfiltered Problems panel:

Windows MAUI MainPage.xaml.cs with zero CA1416 warnings and only the SDK preview information diagnostic

Windows editor/launch context and activated stable extension versions

The language-status popup confirms that both the C# document context and debug target framework are Windows. Its separate Android tooling warning was not a Windows restore or project-load failure.

Windows C# document context and Windows launch target alongside the Problems panel

Activated public stable C# Dev Kit, C#, MAUI, and .NET Install Tool versions

Isolation and scope: SDK environment overrides remained process-local, with DOTNET_ADD_GLOBAL_TOOLS_TO_PATH=0 set before using a temporary DOTNET_CLI_HOME. Installed the template's required MAUI workloads into the private SDK and added .NET 10.0.12 host runtimes side-by-side for stable Dev Kit; no SDK was replaced or silently substituted. The global SDK installation and application/extension source were unchanged. No warning suppression, application build/run, emulator/device launch, or cross-repository rebuild was used.

This is a passing Windows editor smoke test of the fixed SDK, not a fixed-versus-control comparison. Android was not tested because its shared tooling needs updates; iOS/MacCatalyst behavior on macOS remains unvalidated.

@rmarinho
rmarinho marked this pull request as ready for review October 7, 2026 11:27
@rmarinho
rmarinho requested review from a team, lbussell and mthalman as code owners October 7, 2026 11:27
Copilot AI balanced review requested due to automatic review settings October 7, 2026 11:27
Backport the ProjectData host-writer precedence fix from #56516 (7266093) to release/11.0.1xx.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rmarinho
rmarinho force-pushed the rmarinho-net-11-projectdata-backport branch from 4952264 to 2607032 Compare October 7, 2026 11:34

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.

Copilot review overview

🟢 Approval recommended

The focused import guard preserves standalone behavior and has regression coverage for single, outer, and inner evaluations.

Review effort: Balanced
Findings: None

What changed in this PR

Backports the .NET 11 ProjectData host-writer precedence fix while preserving the SDK’s standalone fallback.

Changes:

  • Guards the bundled ProjectData import when a host writer is already selected.
  • Adds single- and multi-targeting regression coverage.
  • Documents the precedence behavior.
File Description
src/​Tasks/​Microsoft.NET.Build.Tasks/​sdk/​Sdk.targets Adds the host-writer guard.
test/​Microsoft.NET.Build.Tests/​GivenThatWeWantToUseProjectData.cs Tests host precedence across evaluation shapes.
test/​TestAssets/​TestProjects/​ProjectDataHostTargets/​HostProjectData.targets Provides the simulated host writer.
.github/​memory/​ARCHITECTURE.md Documents ProjectData import precedence.

@baronfel baronfel 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.

LGTM, one note about ancillary files.

Comment thread .github/memory/ARCHITECTURE.md Resolved
Address the approved review request on #56522 without changing the ProjectData fix or regression tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 7d2420fc Deployed Oct 7, 2026 by baronfel via pre_activation #8018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants