Repository navigation
Make ProjectAssetsFile available in cross-targeting builds - #57006
Conversation
Move the existing assets-path default and normalization to the common SDK targets so restore queries do not depend on generated NuGet props. Add clean/warm query, custom path, override and build regression coverage. Fixes dotnet#49426 Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change enabling multi-target projects to report the assets path on the first clean restore.
No open issues 🎉
What changed in this PR
Addresses #49426 by making ProjectAssetsFile available during cross-targeting evaluation, allowing multi-target projects to report the assets path on the first clean restore.
Changes:
- Moves the existing assets-path default and normalization into shared SDK targets.
- Preserves explicit overrides and global-property behavior without changing NuGet output locations.
- Adds ten regression cases covering restore/build queries, custom paths, normalization, and property precedence.
The new repository tests still require source-built CI validation; the reported local validation used target-file overlays.
| File | Description |
|---|---|
test/Microsoft.NET.Restore.Tests/GivenThatWeQueryProjectAssetsFile.cs |
Adds single- and multi-target regression coverage for assets-path queries and overrides. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets |
Removes the relocated assets-path initialization. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Common.targets |
Initializes and normalizes the assets path for both outer and inner builds. |
Review effort: Balanced
|
CI triage for The pipeline's only failing test is I updated the PR description with this evidence and replied in the existing review thread. No code change was warranted by this failure or by the review's question about removing the fallback; that design discussion remains open. |
dsplaisted
left a comment
There was a problem hiding this comment.
Looks good. Only concern: How does this relate to evaluation order? Are there places that could be reading or writing the ProjectsAssetsFile property that would get changed based on this?
Share the assets default between dependency-resolution and cross-targeting entry points rather than Common.targets. Keep the original inner-build assignment timing and avoid adding defaults for standalone Common imports or C++ dependency stubs. Add import-precedence and scope regressions. Co-authored-by: Copilot App <[email protected]>
|
@dsplaisted I traced the import order and tested the reads/writes around it. Your concern exposed an unnecessary scope change: Common.targets is also imported by the solution entry point and C++ dependency-stub paths, so putting the default there initialized a property those paths previously left empty. Fixed in d12a2ad4bf57. The two assignments now live in a small shared props file imported at the original inner-build location in dependency-resolution targets, and separately by cross-targeting targets. Common.targets is restored unchanged. This also keeps DesktopBridge's dependency-resolution import order intact. The probes confirmed that generated props/targets, Directory.Build.props/targets, the project body, and BeforeMicrosoftNETSdkTargets keep their earlier read/write ordering and override precedence; global properties remain immutable, and later unconditional overrides still win. There is still an intentional outer-build change: a reader after SDK targets sees the fallback, so an assignment there conditioned on an empty value can stop running (as it already does for inner builds). I documented that rather than claiming arbitrary outer-build hooks are unaffected. I ran 33 evaluation probes each for baseline, the previous placement, and the correction. All 23 corrected single/inner/shared-consumer snapshots match baseline exactly, and all early-hook snapshots match, including outer evaluations. The corrected targets also passed the 12-case clean/warm restore/path matrix plus six ordinary restore/build controls. These are installed SDK 10 source-target-overlay checks, not a local source-built main SDK run. I added 10 import-order/scope regression cases while preserving the original 10. The local repository runner is blocked by the missing .NET 12 bootstrap/redist; current-head CI 1673454 is queued, so the new 20-case source-built run is still pending. The previously reported source-built passes apply only to the earlier commit. |
|
Investigated the latest head I inspected all 12 actual failing results across the four template shards (Linux x64, macOS arm64, Windows Core, Windows FullFramework):
Both package errors also occur in independent main build 1673580, verified in its template console. Later main build 1675206 passes both web cases but still fails the F# snapshot; I checked the actual Windows TRX. Build Analysis's successful known-error classification groups these under #57031, but the NU1103 errors are a distinct mechanism, not snapshot mismatches. No PR-caused failure or necessary code fix was found; the head is unchanged. The overall pipeline is still failed, not green. I updated the description with the current-head regression evidence and have not requested another full retry: #57031 is still open and unfixed in main, so it would predictably remain a blocker. The next useful rerun is after the template snapshot/package fix; no unrelated snapshots, package versions, skips, or check bypasses were added here. |
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Fixes #49426 by making the SDK's existing
ProjectAssetsFilefallback consistent between inner and cross-targeting evaluation. This does not make it a NuGet restore-time output contract: the value is an expected SDK input path, not proof that restore ran or the file exists.Change and evaluation order
Share the existing conditional default and normalization in
Microsoft.NET.Sdk.ProjectAssetsFile.props. Import it fromMicrosoft.PackageDependencyResolution.targetsat the original inner-build assignment point and fromMicrosoft.NET.Sdk.CrossTargeting.targetsafter language/common targets. Do not import inner dependency-resolution targets into the outer build or force generated NuGet props to load during restore.Follow-up
d12a2ad4bf57e53554d4a288a5dd92900511f7dfaddresses the evaluation-order review. The previous Common.targets placement also initialized the property for unrelated Common-only consumers (including the solution entry point) and C++ dependency-stub imports. Common.targets is now restored unchanged, avoiding that broader side effect and retaining the original single-target/inner and DesktopBridge dependency-resolution assignment location.Early imports (
Directory.Build.props/targets, generated NuGet props/targets,BeforeMicrosoftNETSdkTargets), project assignments, and global properties retain precedence. Later unconditional overrides still win. The intentional outer-build change remains: code after SDK targets sees a populated/normalized fallback, so a late assignment conditioned on the property being empty can stop running, as it already does for inner builds. Arbitrary external outer-build readers are not claimed to be unaffected.Regression coverage
GivenThatWeQueryProjectAssetsFilenow contains 20 cases. The original 10 cover clean/warm restore and evaluation, inner queries, JSON output, custom extensions/restore paths, normalization, explicit/global overrides, and build outputs. Eight new cases cover conditional assignments inBeforeMicrosoftNETSdkTargets,Directory.Build.targets, and generated-props/targets-shaped imports, checking the pre-assignment read and final normalized value in single/multi-target projects. Two scope cases check that Common-only evaluation does not set the property and real dependency targets, not the C++ stubs, apply the default.Current-head local evidence
Serial before/after source-target-overlay comparisons passed 33 evaluation probes per version (installed baseline, previous PR, revised placement). Every early reader/writer snapshot was preserved. All 23 revised single/inner/shared-consumer snapshots matched baseline exactly. The other outer differences are the intended fallback/normalization change. Common-only/C++ controls reproduce the broader fallback on the previous PR and remain empty after correction.
The revised overlay also passed the 12-case real-CLI clean/warm/path/override matrix and six ordinary restore/build controls. This uses installed SDK
10.0.300-preview.0.26177.108plus private source-target overlays (Common's task-assembly TFM adjusted to installednet10.0): not a compiled current-main/redist run. The local repository runner was attempted but cannot start without the required local .NET 12 bootstrap SDK/redist. C# syntax, XML parsing, packaging-glob inclusion, and patch whitespace checks passed. Source-built CI has now executed all 20 cases successfully; see below.Current-head source-built CI result
At
d12a2ad4bf57e53554d4a288a5dd92900511f7df, build 1673454 successfully compiled all ten SDK build legs. Its Windows restore-suite TRX confirms all 20 assets-query, override, import-order, and scope regressions Passed against this source-built head. The full restore suite reports 56 passed, 6 not executed, and 0 failed.The overall pipeline is failed, while Build Analysis/Build Insights are successful known-error classifications, not evidence that CI is all green. All 12 actual failing test results were inspected across Linux x64, macOS arm64, Windows Core, and Windows FullFramework:
TemplateEngineSamplesProjectTestMicrosoft.NET.Sdkinstead ofFSharp.NET.Sdk;Microsoft.NET.Sdk.AllWebProjectsRestoreAndBuild(mvc_fs-100)Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation >= 10.0.15; independently reproduced onmainbuild 1673580.AllWebProjectsRestoreAndBuild(api_cs-100)Microsoft.AspNetCore.OpenApi >= 10.0.15; exact main-branch issue #57043, also verified in build 1673580.Although Build Analysis groups these under #57031 at the work-item level, the NU1103 errors are a distinct package-resolution failure, not the F# snapshot mechanism. Main build 1673580 has the same two package errors. In later main build 1675206, both web cases pass but the F# snapshot still fails, as verified in its Windows TRX.
No assets-query regression or corrective code change was identified in this run. No retry was requested: the repeatable snapshot issue #57031 remains unfixed in current main, so another full run would predictably retain that blocker. A clean rerun should follow the template fix rather than changing unrelated snapshots/packages or bypassing checks in this PR.
Earlier source-built CI (previous head only)
At
462c92ff0e49460912aa9819e5e140e8150d4c15, build 1671535 successfully compiled all ten SDK build legs. The Windows restore-suite TRX confirms all 10 original regressions passed against that source-built SDK (suite: 46 passed, 6 not executed, 0 failed). This does not validate the new commit.That pipeline's sole failure was
PersistentStorageTelemetryE2ETests.ItDrainsTelemetryPersistedByTheOtherEntryPoint(False)withExpected string not to be <null>, matching independent main build 1666828 and #56957. No telemetry changes, blind reruns, or check bypasses are included.