Skip to content

[Build] Give the build-task restore its own NuGet project extensions path (APT2260) - #40406

Merged
kubaflo merged 1 commit into
net11from
fix/isolate-buildtask-restore-assets
Nov 18, 2026
Merged

kubaflo merged 1 commit into
net11from
fix/isolate-buildtask-restore-assets

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

Build infrastructure only; no product or test code changes.

Symptom. Windows Pack (and occasionally Build) jobs fail intermittently with APT2260 in Controls.Xaml net11.0-android37.0 Aapt2Link: style attribute 'attr/colorPrimary' not found and other Material attributes. Recent examples are net11 maui-pr 1688582 and candidate maui-pr 1688577. There have been 6 Pack and 2 Build Windows failures since 15 Nov, across branches.

Root cause. eng/Build.props restores Microsoft.Maui.BuildTasks.slnf with BuildTaskOnlyBuild=true first, then the full solution filter, in the same MSBuild process:

  1. Under CI, BuildTaskOnlyBuild=true disables the all-TFM group in Directory.Build.props. The first restore therefore writes a reduced artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets, with import groups only for netstandard2.0, netstandard2.1 and net11.0.
  2. The full restore's evaluations parse those same files into the in-process ProjectRootElementCache, then rewrite them with all TFMs.
  3. That cache does not revalidate timestamps: it is created with autoReloadFromDisk: false, keeps 200 strong MRU entries and holds the rest weakly. Later build evaluations can reuse the stale reduced XML, so platform TFMs lose their buildTransitive package imports, including the Material AndroidAarLibrary items. That produces APT2260. Whether the stale entry survives depends on cache eviction and GC, which is why the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase evaluations of Controls.Xaml (ios/android/windows), Controls.Core (ios/windows) and Graphics (android/windows) have zero package imports from the nuget.g.targets. Passing net11 build 1687936 has the normal import counts. #39779 serialized the two restores (RestoreInParallel=false) but they still shared these generated files. #40206 worked around the same mechanism for Controls.Core with explicit package references.

Fix. For the build-task restore only, Directory.Build.props sets MSBuildProjectExtensionsPath to $(BaseIntermediateOutputPath)buildtasks\, so that restore writes nuget.g.*, project.assets.json and dgspec files under artifacts/obj/<project>/buildtasks/. The full restore and build keep the default artifacts/obj/<project>/ path, and the full restore's evaluations never read the reduced files. Arcade's ProjectLayout.props sets only BaseIntermediateOutputPath, and Microsoft.Common.props defaults MSBuildProjectExtensionsPath after importing Directory.Build.props, so this is the supported place to set it. Nothing in the repo reads these paths directly. Other BuildTaskOnlyBuild callers (eng/cake/dotnet.cake, eng/pipelines/arcade/setup-test-env.yml) restore before every later build, so they also stop overwriting the full assets. The comment in eng/Build.props is updated to match.

Rejected alternatives:

Validation

All runs used SDK 11.0.100 with dotnet msbuild -m:1 -nodeReuse:false.

Minimal standalone repro. A local package with build/net10.0 targets, consumed by a library whose TFMs shrink from net11.0;net10.0 to net11.0 under BuildTaskOnlyBuild=true. The driver runs the reduced restore, then the full restore, then reads the package marker for net10.0:

Run Result
Baseline marker missing (red)
Fix marker present (green)
Fix reverted marker missing (red)
Fix restored marker present (green)
Control: baseline with MSBUILDNOINPROCNODE=1 marker present (green): the in-proc XML cache is the mechanism

Repo-level repro, in Arcade's order. The driver runs a BuildTasks.slnf restore with BuildTaskOnlyBuild=true, then a full Controls.Xaml restore, then an evaluation of Controls.Xaml net11.0-android37.0 that counts AndroidAarLibrary items. All runs used CI=true -p:IncludeMacOSTargetFrameworks=false. MSBUILDPROJECTROOTELEMENTCACHESIZE=100000 stops strong-cache eviction, which makes the CI intermittency deterministic:

Run AndroidAarLibrary (all / Material) Package imports in the build-phase android evaluation
Baseline 0 / 0 (red) 31: the stale reduced nuget.g.targets
Fix 69 / 1 (green) 133
Fix reverted 0 / 0 (red) —
Fix restored 69 / 1 (green) —

With default cache settings the baseline was green locally (69/1), which is consistent with the eviction-dependent intermittency seen in CI.

Other checks.

  • Evaluation with BuildTaskOnlyBuild=true: MSBuildProjectExtensionsPath, RestoreOutputPath and ProjectAssetsFile point at artifacts/obj/Controls.Xaml/buildtasks/. Without it they stay at artifacts/obj/Controls.Xaml/.
  • CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false: build succeeded, 0 warnings. All 12 restored projects wrote their assets under artifacts/obj/<project>/buildtasks/.

The CI proof will be a Pack run's Windows binlog: the full restore's evaluations should no longer import a normal-path nuget.g.targets written by the build-task restore.

Issues Fixed

Intermittent Windows Pack/Build APT2260 failures in maui-pr. No issue is filed; this was found while triaging #40116 CI.

Fixes #

The build-task restore (BuildTasks.slnf with BuildTaskOnlyBuild=true) evaluates
fewer target frameworks than the full restore that follows it in the same
MSBuild process. Both wrote the same obj/<project>/*.nuget.g.props/targets, so
the full restore's evaluations parsed the reduced XML into the in-process
ProjectRootElementCache. Later build evaluations could reuse that cached copy
and miss the package imports for platform target frameworks, which surfaces as
APT2260 (missing Material attributes) in Controls.Xaml's Aapt2Link.

Point MSBuildProjectExtensionsPath at obj/<project>/buildtasks/ for the
build-task restore so the two restores never share generated files.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 23:15 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40406

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40406"

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 23:15 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 23:17 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 23:18 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 23:20 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 23:20 — with GitHub Actions Inactive
@kubaflo
kubaflo merged commit a25e629 into net11 Nov 18, 2026
13 of 24 checks passed
@kubaflo
kubaflo deleted the fix/isolate-buildtask-restore-assets branch November 18, 2026 23:35
@kubaflo kubaflo mentioned this pull request Nov 18, 2026
1 task
SubhikshaSf4851 pushed a commit to SubhikshaSf4851/maui that referenced this pull request Nov 23, 2026
…path (APT2260) (dotnet#40406)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Build infrastructure only; no product or test code changes.

**Symptom.** Windows `Pack` (and occasionally `Build`) jobs fail
intermittently with `APT2260` in `Controls.Xaml` `net11.0-android37.0`
`Aapt2Link`: `style attribute 'attr/colorPrimary' not found` and other
Material attributes. Recent examples are net11 maui-pr
[1688582](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688582)
and candidate maui-pr
[1688577](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688577).
There have been 6 Pack and 2 Build Windows failures since 15 Nov, across
branches.

**Root cause.** `eng/Build.props` restores
`Microsoft.Maui.BuildTasks.slnf` with `BuildTaskOnlyBuild=true` first,
then the full solution filter, in the same MSBuild process:
1. Under CI, `BuildTaskOnlyBuild=true` disables the all-TFM group in
`Directory.Build.props`. The first restore therefore writes a reduced
`artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets`, with
import groups only for `netstandard2.0`, `netstandard2.1` and `net11.0`.
2. The full restore's evaluations parse those same files into the
in-process `ProjectRootElementCache`, then rewrite them with all TFMs.
3. That cache does not revalidate timestamps: it is created with
`autoReloadFromDisk: false`, keeps 200 strong MRU entries and holds the
rest weakly. Later build evaluations can reuse the stale reduced XML, so
platform TFMs lose their `buildTransitive` package imports, including
the Material `AndroidAarLibrary` items. That produces `APT2260`. Whether
the stale entry survives depends on cache eviction and GC, which is why
the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase
evaluations of `Controls.Xaml` (ios/android/windows), `Controls.Core`
(ios/windows) and `Graphics` (android/windows) have zero package imports
from the `nuget.g.targets`. Passing net11 build
[1687936](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687936)
has the normal import counts. dotnet#39779 serialized the two restores
(`RestoreInParallel=false`) but they still shared these generated files.
dotnet#40206 worked around the same mechanism for `Controls.Core` with
explicit package references.

**Fix.** For the build-task restore only, `Directory.Build.props` sets
`MSBuildProjectExtensionsPath` to
`$(BaseIntermediateOutputPath)buildtasks\`, so that restore writes
`nuget.g.*`, `project.assets.json` and dgspec files under
`artifacts/obj/<project>/buildtasks/`. The full restore and build keep
the default `artifacts/obj/<project>/` path, and the full restore's
evaluations never read the reduced files. Arcade's `ProjectLayout.props`
sets only `BaseIntermediateOutputPath`, and `Microsoft.Common.props`
defaults `MSBuildProjectExtensionsPath` after importing
`Directory.Build.props`, so this is the supported place to set it.
Nothing in the repo reads these paths directly. Other
`BuildTaskOnlyBuild` callers (`eng/cake/dotnet.cake`,
`eng/pipelines/arcade/setup-test-env.yml`) restore before every later
build, so they also stop overwriting the full assets. The comment in
`eng/Build.props` is updated to match.

Rejected alternatives:
- `MSBUILDNOINPROCNODE=1`: pipeline-wide behaviour change.
- More explicit package references, as in dotnet#40206: a per-project
workaround that doesn't remove the shared state.
- Disabling project-extension imports: unsafe.

### Validation

All runs used SDK 11.0.100 with `dotnet msbuild -m:1 -nodeReuse:false`.

**Minimal standalone repro.** A local package with `build/net10.0`
targets, consumed by a library whose TFMs shrink from `net11.0;net10.0`
to `net11.0` under `BuildTaskOnlyBuild=true`. The driver runs the
reduced restore, then the full restore, then reads the package marker
for `net10.0`:

| Run | Result |
| --- | --- |
| Baseline | marker missing (red) |
| Fix | marker present (green) |
| Fix reverted | marker missing (red) |
| Fix restored | marker present (green) |
| Control: baseline with `MSBUILDNOINPROCNODE=1` | marker present
(green): the in-proc XML cache is the mechanism |

**Repo-level repro, in Arcade's order.** The driver runs a
`BuildTasks.slnf` restore with `BuildTaskOnlyBuild=true`, then a full
`Controls.Xaml` restore, then an evaluation of `Controls.Xaml`
`net11.0-android37.0` that counts `AndroidAarLibrary` items. All runs
used `CI=true -p:IncludeMacOSTargetFrameworks=false`.
`MSBUILDPROJECTROOTELEMENTCACHESIZE=100000` stops strong-cache eviction,
which makes the CI intermittency deterministic:

| Run | AndroidAarLibrary (all / Material) | Package imports in the
build-phase android evaluation |
| --- | --- | --- |
| Baseline | 0 / 0 (red) | 31: the stale reduced `nuget.g.targets` |
| Fix | 69 / 1 (green) | 133 |
| Fix reverted | 0 / 0 (red) | — |
| Fix restored | 69 / 1 (green) | — |

With default cache settings the baseline was green locally (69/1), which
is consistent with the eviction-dependent intermittency seen in CI.

**Other checks.**
- Evaluation with `BuildTaskOnlyBuild=true`:
`MSBuildProjectExtensionsPath`, `RestoreOutputPath` and
`ProjectAssetsFile` point at `artifacts/obj/Controls.Xaml/buildtasks/`.
Without it they stay at `artifacts/obj/Controls.Xaml/`.
- `CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false`: build
succeeded, 0 warnings. All 12 restored projects wrote their assets under
`artifacts/obj/<project>/buildtasks/`.

The CI proof will be a Pack run's Windows binlog: the full restore's
evaluations should no longer import a normal-path `nuget.g.targets`
written by the build-task restore.

### Issues Fixed

Intermittent Windows Pack/Build `APT2260` failures in maui-pr. No issue
is filed; this was found while triaging dotnet#40116 CI.

Fixes #

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit to kubaflo/maui that referenced this pull request Nov 23, 2026
…path (APT2260) (dotnet#40406)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Build infrastructure only; no product or test code changes.

**Symptom.** Windows `Pack` (and occasionally `Build`) jobs fail
intermittently with `APT2260` in `Controls.Xaml` `net11.0-android37.0`
`Aapt2Link`: `style attribute 'attr/colorPrimary' not found` and other
Material attributes. Recent examples are net11 maui-pr
[1688582](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688582)
and candidate maui-pr
[1688577](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688577).
There have been 6 Pack and 2 Build Windows failures since 15 Nov, across
branches.

**Root cause.** `eng/Build.props` restores
`Microsoft.Maui.BuildTasks.slnf` with `BuildTaskOnlyBuild=true` first,
then the full solution filter, in the same MSBuild process:
1. Under CI, `BuildTaskOnlyBuild=true` disables the all-TFM group in
`Directory.Build.props`. The first restore therefore writes a reduced
`artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets`, with
import groups only for `netstandard2.0`, `netstandard2.1` and `net11.0`.
2. The full restore's evaluations parse those same files into the
in-process `ProjectRootElementCache`, then rewrite them with all TFMs.
3. That cache does not revalidate timestamps: it is created with
`autoReloadFromDisk: false`, keeps 200 strong MRU entries and holds the
rest weakly. Later build evaluations can reuse the stale reduced XML, so
platform TFMs lose their `buildTransitive` package imports, including
the Material `AndroidAarLibrary` items. That produces `APT2260`. Whether
the stale entry survives depends on cache eviction and GC, which is why
the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase
evaluations of `Controls.Xaml` (ios/android/windows), `Controls.Core`
(ios/windows) and `Graphics` (android/windows) have zero package imports
from the `nuget.g.targets`. Passing net11 build
[1687936](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687936)
has the normal import counts. dotnet#39779 serialized the two restores
(`RestoreInParallel=false`) but they still shared these generated files.
dotnet#40206 worked around the same mechanism for `Controls.Core` with
explicit package references.

**Fix.** For the build-task restore only, `Directory.Build.props` sets
`MSBuildProjectExtensionsPath` to
`$(BaseIntermediateOutputPath)buildtasks\`, so that restore writes
`nuget.g.*`, `project.assets.json` and dgspec files under
`artifacts/obj/<project>/buildtasks/`. The full restore and build keep
the default `artifacts/obj/<project>/` path, and the full restore's
evaluations never read the reduced files. Arcade's `ProjectLayout.props`
sets only `BaseIntermediateOutputPath`, and `Microsoft.Common.props`
defaults `MSBuildProjectExtensionsPath` after importing
`Directory.Build.props`, so this is the supported place to set it.
Nothing in the repo reads these paths directly. Other
`BuildTaskOnlyBuild` callers (`eng/cake/dotnet.cake`,
`eng/pipelines/arcade/setup-test-env.yml`) restore before every later
build, so they also stop overwriting the full assets. The comment in
`eng/Build.props` is updated to match.

Rejected alternatives:
- `MSBUILDNOINPROCNODE=1`: pipeline-wide behaviour change.
- More explicit package references, as in dotnet#40206: a per-project
workaround that doesn't remove the shared state.
- Disabling project-extension imports: unsafe.

### Validation

All runs used SDK 11.0.100 with `dotnet msbuild -m:1 -nodeReuse:false`.

**Minimal standalone repro.** A local package with `build/net10.0`
targets, consumed by a library whose TFMs shrink from `net11.0;net10.0`
to `net11.0` under `BuildTaskOnlyBuild=true`. The driver runs the
reduced restore, then the full restore, then reads the package marker
for `net10.0`:

| Run | Result |
| --- | --- |
| Baseline | marker missing (red) |
| Fix | marker present (green) |
| Fix reverted | marker missing (red) |
| Fix restored | marker present (green) |
| Control: baseline with `MSBUILDNOINPROCNODE=1` | marker present
(green): the in-proc XML cache is the mechanism |

**Repo-level repro, in Arcade's order.** The driver runs a
`BuildTasks.slnf` restore with `BuildTaskOnlyBuild=true`, then a full
`Controls.Xaml` restore, then an evaluation of `Controls.Xaml`
`net11.0-android37.0` that counts `AndroidAarLibrary` items. All runs
used `CI=true -p:IncludeMacOSTargetFrameworks=false`.
`MSBUILDPROJECTROOTELEMENTCACHESIZE=100000` stops strong-cache eviction,
which makes the CI intermittency deterministic:

| Run | AndroidAarLibrary (all / Material) | Package imports in the
build-phase android evaluation |
| --- | --- | --- |
| Baseline | 0 / 0 (red) | 31: the stale reduced `nuget.g.targets` |
| Fix | 69 / 1 (green) | 133 |
| Fix reverted | 0 / 0 (red) | — |
| Fix restored | 69 / 1 (green) | — |

With default cache settings the baseline was green locally (69/1), which
is consistent with the eviction-dependent intermittency seen in CI.

**Other checks.**
- Evaluation with `BuildTaskOnlyBuild=true`:
`MSBuildProjectExtensionsPath`, `RestoreOutputPath` and
`ProjectAssetsFile` point at `artifacts/obj/Controls.Xaml/buildtasks/`.
Without it they stay at `artifacts/obj/Controls.Xaml/`.
- `CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false`: build
succeeded, 0 warnings. All 12 restored projects wrote their assets under
`artifacts/obj/<project>/buildtasks/`.

The CI proof will be a Pack run's Windows binlog: the full restore's
evaluations should no longer import a normal-path `nuget.g.targets`
written by the build-task restore.

### Issues Fixed

Intermittent Windows Pack/Build `APT2260` failures in maui-pr. No issue
is filed; this was found while triaging dotnet#40116 CI.

Fixes #

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request Nov 25, 2026
…path (APT2260) (dotnet#40406)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Build infrastructure only; no product or test code changes.

**Symptom.** Windows `Pack` (and occasionally `Build`) jobs fail
intermittently with `APT2260` in `Controls.Xaml` `net11.0-android37.0`
`Aapt2Link`: `style attribute 'attr/colorPrimary' not found` and other
Material attributes. Recent examples are net11 maui-pr
[1688582](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688582)
and candidate maui-pr
[1688577](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688577).
There have been 6 Pack and 2 Build Windows failures since 15 Nov, across
branches.

**Root cause.** `eng/Build.props` restores
`Microsoft.Maui.BuildTasks.slnf` with `BuildTaskOnlyBuild=true` first,
then the full solution filter, in the same MSBuild process:
1. Under CI, `BuildTaskOnlyBuild=true` disables the all-TFM group in
`Directory.Build.props`. The first restore therefore writes a reduced
`artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets`, with
import groups only for `netstandard2.0`, `netstandard2.1` and `net11.0`.
2. The full restore's evaluations parse those same files into the
in-process `ProjectRootElementCache`, then rewrite them with all TFMs.
3. That cache does not revalidate timestamps: it is created with
`autoReloadFromDisk: false`, keeps 200 strong MRU entries and holds the
rest weakly. Later build evaluations can reuse the stale reduced XML, so
platform TFMs lose their `buildTransitive` package imports, including
the Material `AndroidAarLibrary` items. That produces `APT2260`. Whether
the stale entry survives depends on cache eviction and GC, which is why
the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase
evaluations of `Controls.Xaml` (ios/android/windows), `Controls.Core`
(ios/windows) and `Graphics` (android/windows) have zero package imports
from the `nuget.g.targets`. Passing net11 build
[1687936](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687936)
has the normal import counts. dotnet#39779 serialized the two restores
(`RestoreInParallel=false`) but they still shared these generated files.
dotnet#40206 worked around the same mechanism for `Controls.Core` with
explicit package references.

**Fix.** For the build-task restore only, `Directory.Build.props` sets
`MSBuildProjectExtensionsPath` to
`$(BaseIntermediateOutputPath)buildtasks\`, so that restore writes
`nuget.g.*`, `project.assets.json` and dgspec files under
`artifacts/obj/<project>/buildtasks/`. The full restore and build keep
the default `artifacts/obj/<project>/` path, and the full restore's
evaluations never read the reduced files. Arcade's `ProjectLayout.props`
sets only `BaseIntermediateOutputPath`, and `Microsoft.Common.props`
defaults `MSBuildProjectExtensionsPath` after importing
`Directory.Build.props`, so this is the supported place to set it.
Nothing in the repo reads these paths directly. Other
`BuildTaskOnlyBuild` callers (`eng/cake/dotnet.cake`,
`eng/pipelines/arcade/setup-test-env.yml`) restore before every later
build, so they also stop overwriting the full assets. The comment in
`eng/Build.props` is updated to match.

Rejected alternatives:
- `MSBUILDNOINPROCNODE=1`: pipeline-wide behaviour change.
- More explicit package references, as in dotnet#40206: a per-project
workaround that doesn't remove the shared state.
- Disabling project-extension imports: unsafe.

### Validation

All runs used SDK 11.0.100 with `dotnet msbuild -m:1 -nodeReuse:false`.

**Minimal standalone repro.** A local package with `build/net10.0`
targets, consumed by a library whose TFMs shrink from `net11.0;net10.0`
to `net11.0` under `BuildTaskOnlyBuild=true`. The driver runs the
reduced restore, then the full restore, then reads the package marker
for `net10.0`:

| Run | Result |
| --- | --- |
| Baseline | marker missing (red) |
| Fix | marker present (green) |
| Fix reverted | marker missing (red) |
| Fix restored | marker present (green) |
| Control: baseline with `MSBUILDNOINPROCNODE=1` | marker present
(green): the in-proc XML cache is the mechanism |

**Repo-level repro, in Arcade's order.** The driver runs a
`BuildTasks.slnf` restore with `BuildTaskOnlyBuild=true`, then a full
`Controls.Xaml` restore, then an evaluation of `Controls.Xaml`
`net11.0-android37.0` that counts `AndroidAarLibrary` items. All runs
used `CI=true -p:IncludeMacOSTargetFrameworks=false`.
`MSBUILDPROJECTROOTELEMENTCACHESIZE=100000` stops strong-cache eviction,
which makes the CI intermittency deterministic:

| Run | AndroidAarLibrary (all / Material) | Package imports in the
build-phase android evaluation |
| --- | --- | --- |
| Baseline | 0 / 0 (red) | 31: the stale reduced `nuget.g.targets` |
| Fix | 69 / 1 (green) | 133 |
| Fix reverted | 0 / 0 (red) | — |
| Fix restored | 69 / 1 (green) | — |

With default cache settings the baseline was green locally (69/1), which
is consistent with the eviction-dependent intermittency seen in CI.

**Other checks.**
- Evaluation with `BuildTaskOnlyBuild=true`:
`MSBuildProjectExtensionsPath`, `RestoreOutputPath` and
`ProjectAssetsFile` point at `artifacts/obj/Controls.Xaml/buildtasks/`.
Without it they stay at `artifacts/obj/Controls.Xaml/`.
- `CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false`: build
succeeded, 0 warnings. All 12 restored projects wrote their assets under
`artifacts/obj/<project>/buildtasks/`.

The CI proof will be a Pack run's Windows binlog: the full restore's
evaluations should no longer import a normal-path `nuget.g.targets`
written by the build-task restore.

### Issues Fixed

Intermittent Windows Pack/Build `APT2260` failures in maui-pr. No issue
is filed; this was found while triaging dotnet#40116 CI.

Fixes #

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…path (APT2260) (dotnet#40406)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Build infrastructure only; no product or test code changes.

**Symptom.** Windows `Pack` (and occasionally `Build`) jobs fail
intermittently with `APT2260` in `Controls.Xaml` `net11.0-android37.0`
`Aapt2Link`: `style attribute 'attr/colorPrimary' not found` and other
Material attributes. Recent examples are net11 maui-pr
[1688582](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688582)
and candidate maui-pr
[1688577](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688577).
There have been 6 Pack and 2 Build Windows failures since 15 Nov, across
branches.

**Root cause.** `eng/Build.props` restores
`Microsoft.Maui.BuildTasks.slnf` with `BuildTaskOnlyBuild=true` first,
then the full solution filter, in the same MSBuild process:
1. Under CI, `BuildTaskOnlyBuild=true` disables the all-TFM group in
`Directory.Build.props`. The first restore therefore writes a reduced
`artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets`, with
import groups only for `netstandard2.0`, `netstandard2.1` and `net11.0`.
2. The full restore's evaluations parse those same files into the
in-process `ProjectRootElementCache`, then rewrite them with all TFMs.
3. That cache does not revalidate timestamps: it is created with
`autoReloadFromDisk: false`, keeps 200 strong MRU entries and holds the
rest weakly. Later build evaluations can reuse the stale reduced XML, so
platform TFMs lose their `buildTransitive` package imports, including
the Material `AndroidAarLibrary` items. That produces `APT2260`. Whether
the stale entry survives depends on cache eviction and GC, which is why
the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase
evaluations of `Controls.Xaml` (ios/android/windows), `Controls.Core`
(ios/windows) and `Graphics` (android/windows) have zero package imports
from the `nuget.g.targets`. Passing net11 build
[1687936](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687936)
has the normal import counts. dotnet#39779 serialized the two restores
(`RestoreInParallel=false`) but they still shared these generated files.
dotnet#40206 worked around the same mechanism for `Controls.Core` with
explicit package references.

**Fix.** For the build-task restore only, `Directory.Build.props` sets
`MSBuildProjectExtensionsPath` to
`$(BaseIntermediateOutputPath)buildtasks\`, so that restore writes
`nuget.g.*`, `project.assets.json` and dgspec files under
`artifacts/obj/<project>/buildtasks/`. The full restore and build keep
the default `artifacts/obj/<project>/` path, and the full restore's
evaluations never read the reduced files. Arcade's `ProjectLayout.props`
sets only `BaseIntermediateOutputPath`, and `Microsoft.Common.props`
defaults `MSBuildProjectExtensionsPath` after importing
`Directory.Build.props`, so this is the supported place to set it.
Nothing in the repo reads these paths directly. Other
`BuildTaskOnlyBuild` callers (`eng/cake/dotnet.cake`,
`eng/pipelines/arcade/setup-test-env.yml`) restore before every later
build, so they also stop overwriting the full assets. The comment in
`eng/Build.props` is updated to match.

Rejected alternatives:
- `MSBUILDNOINPROCNODE=1`: pipeline-wide behaviour change.
- More explicit package references, as in dotnet#40206: a per-project
workaround that doesn't remove the shared state.
- Disabling project-extension imports: unsafe.

### Validation

All runs used SDK 11.0.100 with `dotnet msbuild -m:1 -nodeReuse:false`.

**Minimal standalone repro.** A local package with `build/net10.0`
targets, consumed by a library whose TFMs shrink from `net11.0;net10.0`
to `net11.0` under `BuildTaskOnlyBuild=true`. The driver runs the
reduced restore, then the full restore, then reads the package marker
for `net10.0`:

| Run | Result |
| --- | --- |
| Baseline | marker missing (red) |
| Fix | marker present (green) |
| Fix reverted | marker missing (red) |
| Fix restored | marker present (green) |
| Control: baseline with `MSBUILDNOINPROCNODE=1` | marker present
(green): the in-proc XML cache is the mechanism |

**Repo-level repro, in Arcade's order.** The driver runs a
`BuildTasks.slnf` restore with `BuildTaskOnlyBuild=true`, then a full
`Controls.Xaml` restore, then an evaluation of `Controls.Xaml`
`net11.0-android37.0` that counts `AndroidAarLibrary` items. All runs
used `CI=true -p:IncludeMacOSTargetFrameworks=false`.
`MSBUILDPROJECTROOTELEMENTCACHESIZE=100000` stops strong-cache eviction,
which makes the CI intermittency deterministic:

| Run | AndroidAarLibrary (all / Material) | Package imports in the
build-phase android evaluation |
| --- | --- | --- |
| Baseline | 0 / 0 (red) | 31: the stale reduced `nuget.g.targets` |
| Fix | 69 / 1 (green) | 133 |
| Fix reverted | 0 / 0 (red) | — |
| Fix restored | 69 / 1 (green) | — |

With default cache settings the baseline was green locally (69/1), which
is consistent with the eviction-dependent intermittency seen in CI.

**Other checks.**
- Evaluation with `BuildTaskOnlyBuild=true`:
`MSBuildProjectExtensionsPath`, `RestoreOutputPath` and
`ProjectAssetsFile` point at `artifacts/obj/Controls.Xaml/buildtasks/`.
Without it they stay at `artifacts/obj/Controls.Xaml/`.
- `CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false`: build
succeeded, 0 warnings. All 12 restored projects wrote their assets under
`artifacts/obj/<project>/buildtasks/`.

The CI proof will be a Pack run's Windows binlog: the full restore's
evaluations should no longer import a normal-path `nuget.g.targets`
written by the build-task restore.

### Issues Fixed

Intermittent Windows Pack/Build `APT2260` failures in maui-pr. No issue
is filed; this was found while triaging dotnet#40116 CI.

Fixes #

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

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 8661636e Deployed Nov 18, 2026 by kubaflo via conclusion #3106
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.

1 participant