Repository navigation
Predict RID-agnostic project references in isolated graph builds - #15744
Open
AlesProkop wants to merge 2 commits into
Open
AlesProkop wants to merge 2 commits into
AlesProkop wants to merge 2 commits into
Conversation
In isolated graph builds, a project reference that the SDK considers RID-agnostic is built without RuntimeIdentifier and SelfContained, but the graph created its node with the inherited properties, causing MSB4252. Evaluate the reference without those properties, as GetTargetFrameworks does, and drop them from the graph node when every target framework is RID-agnostic. Gated behind ChangeWave 18.15. Fixes dotnet#15711 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AlesProkop
marked this pull request as ready for review
December 2, 2026 12:31
AlesProkop
temporarily deployed
to
copilot-pat-pool
December 2, 2026 12:31 — with
GitHub Actions
Inactive
AlesProkop
temporarily deployed
to
copilot-pat-pool
December 2, 2026 12:31 — with
GitHub Actions
Inactive
AlesProkop
temporarily deployed
to
copilot-pat-pool
December 2, 2026 12:31 — with
GitHub Actions
Inactive
AlesProkop
temporarily deployed
to
copilot-pat-pool
December 2, 2026 12:32 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Incorrect Boolean-alias handling can remove required runtime properties during graph prediction, causing configuration mismatches and MSB4252 failures in isolated builds.
2 open issues
What changed in this PR
Aligns isolated static graph builds with runtime project-reference handling so RID-agnostic libraries can build without MSB4252.
Changes:
- Predicts RID-less reference configurations and reuses discovery evaluations.
- Limits prediction to eligible single-entry isolated builds behind ChangeWave 18.15.
- Adds regression coverage and documents the behavior.
| File | Description |
|---|---|
| src/Build/Graph/ProjectInterpretation.cs | Detects eligible RID-agnostic references. |
| src/Build/Graph/ProjectGraphOptions.cs | Adds an internal prediction option. |
| src/Build/Graph/ProjectGraph.cs | Passes the option to graph construction. |
| src/Build/Graph/GraphBuilder.cs | Restricts entry points and reuses cached evaluations. |
| src/Build/BackEnd/BuildManager/BuildManager.cs | Enables prediction for eligible isolated builds. |
| src/Build.UnitTests/Graph/ProjectReferenceTargetsProtocol_Tests.cs | Tests isolation, metadata, multitargeting, and entry-point handling. |
| documentation/wiki/ChangeWaves.md | Documents the 18.15 behavior and scope. |
Review effort: Balanced
| && !enableDynamicPlatformResolution | ||
| && (referenceGlobalProperties.Contains("RuntimeIdentifier") || referenceGlobalProperties.Contains("SelfContained")) | ||
| && (usesCommonReferenceProtocol ??= UsesCommonReferenceProtocol(requesterInstance)) | ||
| && !projectReferenceItem.GetMetadataValue("SkipGetTargetFrameworkProperties").Equals("true", StringComparison.OrdinalIgnoreCase) |
| string isRidAgnostic = project.GetPropertyValue("IsRidAgnostic"); | ||
| return string.IsNullOrEmpty(isRidAgnostic) | ||
| ? string.IsNullOrEmpty(project.GetPropertyValue("RuntimeIdentifier")) && string.IsNullOrEmpty(project.GetPropertyValue("RuntimeIdentifiers")) | ||
| : !isRidAgnostic.Equals("false", StringComparison.OrdinalIgnoreCase); |
AlesProkop
temporarily deployed
to
copilot-pat-pool
December 2, 2026 12:44 — with
GitHub Actions
Inactive
AlesProkop
temporarily deployed
to
copilot-pat-pool
December 2, 2026 12:45 — with
GitHub Actions
Inactive
AlesProkop
had a problem deploying
to
copilot-pat-pool
December 2, 2026 12:46 — with
GitHub Actions
Failure
- Decline prediction instead of recursing when an inner build still evaluates as an outer build. - Only predict when the requester's Build dependency chain reaches ResolveProjectReferences. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch had an error being 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.

Related issue(s): Fixes #15711
Context
dotnet build -graph -isolate -r <rid>fails with MSB4252 for a console app referencing a plain class library. At execution time,_GetProjectReferenceTargetFrameworkPropertiesfinds that the library isIsRidAgnosticand builds it withoutRuntimeIdentifier/SelfContained. The static graph, however, created the library node with those properties inherited, so isolation rejects the undeclared reference configuration.Changes Made
ProjectInterpretation.GetReferences: when enabled, evaluate each reference that follows the common reference protocol withoutRuntimeIdentifier/SelfContained, the same wayGetTargetFrameworksdoes. If it is RID-agnostic under the same rules as the targets (IsRidAgnostic, else noRuntimeIdentifier/RuntimeIdentifiers), create the graph node without those properties. For multitargeted references, every inner build must be RID-agnostic, because nearest-framework selection happens at execution time.SkipGetTargetFrameworkProperties=true,SetTargetFramework,.vcxproj/.nativeprojdefaults, dynamic platform resolution, outer-build requesters, and projects that don't use the commonBuild/GetTargetFrameworksprotocol.GraphBuilderreuses the cached discovery evaluation for the node, so nothing is evaluated twice.BuildManagerfor isolated graph builds (ProjectIsolationMode.True) that build only theBuildtarget and have a single entry point, via an internalProjectGraphOptions.PredictRidAgnosticReferences. The publicProjectGraphconstruction and restore graphs are unchanged.Compatibility
Gated behind ChangeWave 18.15 (documented in
ChangeWaves.md). Only isolated graph builds are affected. Non-isolated graph builds, non-graph builds, and builds without a RID are unchanged.Known limitation: a RID-sensitive library (for example, one that sets
RuntimeIdentifiers) referenced this way still fails with MSB4252, as before. Supporting it would need separate discovery and build configurations.Testing
build.cmd -v quiet: 0 warnings, 0 errors.ProjectReferenceTargetsProtocolTests: 46/46 on net11.0 and net472, including new tests for in-proc and out-of-proc isolated builds, metadata and multitargeting cases, and multiple entry points. The wave-disabled case asserts MSB4252.Microsoft.Build.Graph.UnitTestsnamespace: 644 passed, 8 skipped, 0 failed (net11.0 + net472).*IsolateProjects*: 88 passed, 0 failed.dotnet restore app -r win-x64, thendotnet build app -graph -isolate -r win-x64 --no-restore):MSBUILDDISABLEFEATURESFROMVERSION=18.15, MSB4252 returns.net11.0;netstandard2.1lib all pass.RuntimeIdentifiersset) still fails (the known limitation above).