Repository navigation
[Build] Give the build-task restore its own NuGet project extensions path (APT2260) - #40406
Merged
Merged
Conversation
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
temporarily deployed
to
copilot-pat-pool
November 18, 2026 23:15 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40406Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40406" |
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 23:15 — with
GitHub Actions
Inactive
This comment has been minimized.
This comment has been minimized.
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 23:17 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 23:18 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 23:20 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 23:20 — with
GitHub Actions
Inactive
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>
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainnet11, for reviewFor .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 occasionallyBuild) jobs fail intermittently withAPT2260inControls.Xamlnet11.0-android37.0Aapt2Link:style attribute 'attr/colorPrimary' not foundand 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.propsrestoresMicrosoft.Maui.BuildTasks.slnfwithBuildTaskOnlyBuild=truefirst, then the full solution filter, in the same MSBuild process:BuildTaskOnlyBuild=truedisables the all-TFM group inDirectory.Build.props. The first restore therefore writes a reducedartifacts/obj/<project>/<project>.csproj.nuget.g.props/targets, with import groups only fornetstandard2.0,netstandard2.1andnet11.0.ProjectRootElementCache, then rewrite them with all TFMs.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 theirbuildTransitivepackage imports, including the MaterialAndroidAarLibraryitems. That producesAPT2260. 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) andGraphics(android/windows) have zero package imports from thenuget.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 forControls.Corewith explicit package references.Fix. For the build-task restore only,
Directory.Build.propssetsMSBuildProjectExtensionsPathto$(BaseIntermediateOutputPath)buildtasks\, so that restore writesnuget.g.*,project.assets.jsonand dgspec files underartifacts/obj/<project>/buildtasks/. The full restore and build keep the defaultartifacts/obj/<project>/path, and the full restore's evaluations never read the reduced files. Arcade'sProjectLayout.propssets onlyBaseIntermediateOutputPath, andMicrosoft.Common.propsdefaultsMSBuildProjectExtensionsPathafter importingDirectory.Build.props, so this is the supported place to set it. Nothing in the repo reads these paths directly. OtherBuildTaskOnlyBuildcallers (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 ineng/Build.propsis updated to match.Rejected alternatives:
MSBUILDNOINPROCNODE=1: pipeline-wide behaviour change.Validation
All runs used SDK 11.0.100 with
dotnet msbuild -m:1 -nodeReuse:false.Minimal standalone repro. A local package with
build/net10.0targets, consumed by a library whose TFMs shrink fromnet11.0;net10.0tonet11.0underBuildTaskOnlyBuild=true. The driver runs the reduced restore, then the full restore, then reads the package marker fornet10.0:MSBUILDNOINPROCNODE=1Repo-level repro, in Arcade's order. The driver runs a
BuildTasks.slnfrestore withBuildTaskOnlyBuild=true, then a fullControls.Xamlrestore, then an evaluation ofControls.Xamlnet11.0-android37.0that countsAndroidAarLibraryitems. All runs usedCI=true -p:IncludeMacOSTargetFrameworks=false.MSBUILDPROJECTROOTELEMENTCACHESIZE=100000stops strong-cache eviction, which makes the CI intermittency deterministic:nuget.g.targetsWith default cache settings the baseline was green locally (69/1), which is consistent with the eviction-dependent intermittency seen in CI.
Other checks.
BuildTaskOnlyBuild=true:MSBuildProjectExtensionsPath,RestoreOutputPathandProjectAssetsFilepoint atartifacts/obj/Controls.Xaml/buildtasks/. Without it they stay atartifacts/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 underartifacts/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.targetswritten by the build-task restore.Issues Fixed
Intermittent Windows Pack/Build
APT2260failures in maui-pr. No issue is filed; this was found while triaging #40116 CI.Fixes #