Move core ProjectReferenceTargets from Managed-only to Common targets#13427
Open
dfederm wants to merge 6 commits into
Open
Move core ProjectReferenceTargets from Managed-only to Common targets#13427dfederm wants to merge 6 commits into
dfederm wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Moves the static-graph ProjectReferenceTargets protocol for core Build/Clean/Rebuild from managed-only targets into the common MSBuild targets so it applies to all project types that import the common targets, aligning implementation with the static graph spec.
Changes:
- Added core static-graph
ProjectReferenceTargets(Build/Clean/Rebuild) toMicrosoft.Common.CurrentVersion.targets. - Added cross-targeting (outer build) static-graph
ProjectReferenceTargetsdispatch protocol toMicrosoft.Common.CrossTargeting.targets. - Refactored managed
DeployOnBuildpropagation from property composition to item-based composition and added new unit tests + doc updates.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Tasks/Microsoft.Managed.After.targets | Removes core Build/Clean/Rebuild protocol and keeps managed-only Publish/DeployOnBuild extensions. |
| src/Tasks/Microsoft.Common.CurrentVersion.targets | Defines core Build/Clean/Rebuild ProjectReferenceTargets protocol for static graph builds. |
| src/Tasks/Microsoft.Common.CrossTargeting.targets | Defines cross-targeting (outer build) static graph protocol for Build/Clean/Rebuild. |
| src/Build.UnitTests/Graph/ProjectReferenceTargetsProtocol_Tests.cs | Adds unit tests validating protocol behavior across managed/non-managed and cross-targeting scenarios. |
| documentation/ProjectReference-Protocol.md | Updates links and clarifies references to protocol/comment locations in targets files. |
3dd7d04 to
57fbc44
Compare
Contributor
Author
|
/azp run |
|
Commenter does not have sufficient privileges for PR 13427 in repo dotnet/msbuild |
rainersigwald
approved these changes
May 12, 2026
dfederm
pushed a commit
to dfederm/msbuild
that referenced
this pull request
May 12, 2026
…of snapshotting protocol XML Addresses Rainer's review comment on PR dotnet#13427. The test now imports Microsoft.Common.targets, Microsoft.Common.CrossTargeting.targets, and Microsoft.Managed.After.targets via $(MSBuildToolsPath) rather than carrying copy-pasted snapshots of their ProjectReferenceTargets sections. Future drift between the graph evaluator and the real protocol will now fire these tests directly instead of leaving them silently stale. Cross-targeting tests pass a NuGetRestoreTargets stub path because Microsoft.Common.CrossTargeting.targets imports $(NuGetRestoreTargets)`nunconditionally (no Exists() guard, unlike Common.CurrentVersion.targets). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dfederm
pushed a commit
to dfederm/msbuild
that referenced
this pull request
May 13, 2026
…of snapshotting protocol XML Addresses Rainer's review comment on PR dotnet#13427. The test now imports Microsoft.Common.targets, Microsoft.Common.CrossTargeting.targets, and Microsoft.Managed.After.targets via $(MSBuildToolsPath) rather than carrying copy-pasted snapshots of their ProjectReferenceTargets sections. Future drift between the graph evaluator and the real protocol will now fire these tests directly instead of leaving them silently stale. Cross-targeting tests pass a NuGetRestoreTargets stub path because Microsoft.Common.CrossTargeting.targets imports $(NuGetRestoreTargets)`nunconditionally (no Exists() guard, unlike Common.CurrentVersion.targets). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
062f8fd to
8ca1587
Compare
Move the core Build/Clean/Rebuild ProjectReferenceTargets protocol from Microsoft.Managed.After.targets into Microsoft.Common.CurrentVersion.targets so it applies to all project types that import the common targets, not just managed languages (C#, VB, F#). This aligns with the static graph spec which prescribes that common protocols be defined in the common targets. Extract the cross-targeting outer build protocol (using .default dispatch) into Microsoft.Common.CrossTargeting.targets where it naturally belongs alongside the DispatchToInnerBuilds target. Refactor DeployOnBuild handling from property-level composition (appending Publish targets to the ProjectReferenceTargetsForBuild property) to item-level composition (separate ProjectReferenceTargets items). This is functionally equivalent since the static graph engine merges all items with the same Include value, and eliminates a subtle duplication in the old code. Microsoft.Managed.After.targets retains managed-specific extensions: Publish, DeployOnBuild, GetCopyToPublishDirectoryItems, WPF graph isolation, and the InnerBuildProperty/InnerBuildPropertyValues definitions. Also fixes: - Update docs.microsoft.com URL to learn.microsoft.com - Convert absolute GitHub links to relative paths in protocol docs - Add prose hints for deep-link references into large targets files - Fix typo: GetTargetFrameworksWithPlatformForSingleTargetFrameworks (plural) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix 'managed languaged' typo in Microsoft.Managed.After.targets - Make _env field readonly in ProjectReferenceTargetsProtocolTests - Add clarifying comment explaining why outer build includes both protocols Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
Add ProjectReferenceTargetsForBuildInOuterBuild and ProjectReferenceTargetsForCleanInOuterBuild items to Microsoft.Common.CrossTargeting.targets to preserve the extensibility points that were previously available in outer builds via Microsoft.Managed.After.targets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…of snapshotting protocol XML Addresses Rainer's review comment on PR dotnet#13427. The test now imports Microsoft.Common.targets, Microsoft.Common.CrossTargeting.targets, and Microsoft.Managed.After.targets via $(MSBuildToolsPath) rather than carrying copy-pasted snapshots of their ProjectReferenceTargets sections. Future drift between the graph evaluator and the real protocol will now fire these tests directly instead of leaving them silently stale. Cross-targeting tests pass a NuGetRestoreTargets stub path because Microsoft.Common.CrossTargeting.targets imports $(NuGetRestoreTargets)`nunconditionally (no Exists() guard, unlike Common.CurrentVersion.targets). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8ca1587 to
bab1fb4
Compare
Contributor
Author
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.
Summary
Move the core Build/Clean/Rebuild
ProjectReferenceTargetsprotocol fromMicrosoft.Managed.After.targetsintoMicrosoft.Common.CurrentVersion.targetsso it applies to all project types that import the common targets, not just managed languages (C#, VB, F#). This aligns with the static graph spec which prescribes that common protocols be defined in the common targets.What changed
Targets files
Microsoft.Common.CurrentVersion.targets: Now contains the coreProjectReferenceTargetsfor Build, Clean, and Rebuild, includingOuterBuilditems,SkipNonexistentTargetsitems, and the extensibility properties (ProjectReferenceTargetsForBuild, etc.)Microsoft.Common.CrossTargeting.targets: Now contains the cross-targeting outer build protocol (.defaultdispatch) that was previously inlined inManaged.After.targetsMicrosoft.Managed.After.targets: Retains only managed-specific extensions: Publish, DeployOnBuild,GetCopyToPublishDirectoryItems, WPF graph isolation, andInnerBuildProperty/InnerBuildPropertyValuesDeployOnBuild refactor
DeployOnBuild handling changed from property-level composition (appending Publish targets to
$(ProjectReferenceTargetsForBuild)) to item-level composition (separateProjectReferenceTargetsitems). This is functionally equivalent since the static graph engine merges all items with the sameIncludevalue, and eliminates a subtle duplication in the old code whereProjectReferenceTargetsForRebuildincluded publish targets twice.Documentation
docs.microsoft.com→learn.microsoft.comURLTesting
Unit tests (11 new, all passing)
New file
src/Build.UnitTests/Graph/ProjectReferenceTargetsProtocol_Tests.cscovering:.defaultdispatchBuildProjectReferences=falseandNoBuild=truefallbacksManual validation
Tested with old (VS 18 Canary) vs new (bootstrap) MSBuild:
.projwith/graph /isolate— old MSBuild producesMSB4252isolation violation ("target not specified in ProjectReferenceTargets"), new MSBuild resolves the graph correctly-getItem:ProjectReferenceTargets /p:IsGraphBuild=trueon non-managed.proj: old returns empty, new returns full Build/Clean/Rebuild protocol fromMicrosoft.Common.CurrentVersion.targets