Enable /graph in CI builds, dev builds, and PR builds#53607
Open
Enable /graph in CI builds, dev builds, and PR builds#53607
Conversation
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/efc7cf71-2ee4-4f93-b888-494874161c1e Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
marcpopMSFT
March 27, 2026 00:00
View session
Member
|
@copilot can this be added to a directory.build.rsp file in the root of the repo instead? |
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/65f8b05b-ea0c-44e6-bab9-ac3a5153942e Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Contributor
Author
Done in ec698e7. Reverted the per-script additions and added a |
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Enables MSBuild static graph mode across builds by introducing a repo-level response file intended to add /graph to MSBuild invocations.
Changes:
- Add
Directory.Build.rspat the repo root containing/graphto enable static graph builds by default.
Member
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
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
Enables MSBuild's static graph build mode (
/graph) for all build types to speed up builds.Changes
Directory.Build.rsp— new file at the repo root containing/graph, which MSBuild automatically picks up for every invocation (dev, CI, and PR builds on all platforms)Why
/graph?MSBuild's static graph (
/graph) mode pre-evaluates the project dependency graph before building, which allows for better scheduling and parallelism across projects. This speeds up builds, particularly in repos with many projects like the SDK.MSBuild
/graphBuild Performance AnalysisSummary
Enabling MSBuild's
/graphflag on the dotnet/sdk repo cuts no-op incremental build time by ~52% (8.5 min → 4.1 min wall-clock). Graph build pre-computes the project dependency graph statically, eliminating redundant recursive traversal of project references that dominates incremental build cost.Test Setup
build.cmd /bl(baseline) vsbuild.cmd /bl /graphscripts/BinlogAnalyzer/)Results
Wall-Clock Time
/graph/graphTarget-Level Comparison (Cumulative Time)
/graph/graphResolveProjectReferencesMsCoverageReferencedPathMapsDispatchToInnerBuildsGetCopyToOutputDirectoryItems_GetProjectReferenceTargetFrameworkPropertiesTask-Level Comparison (Cumulative Time)
/graph/graphMSBuild(recursive invocations)Csc(compilation)CopyKey Observations
/graphhalved wall-clock time. The biggest gain comes from eliminating redundant project reference traversal. In standard mode, MSBuild recursively invokesResolveProjectReferenceson every project and its transitive dependencies. Graph build pre-computes the full dependency graph, building projects in topological order without redundant re-evaluation.MsCoverageReferencedPathMapsdropped from 187 min to 3 min cumulative. This code coverage instrumentation target was being invoked deeply in the recursive project graph traversal. With graph build, it no longer runs redundantly across transitive references.Zero compilations on no-op with
/graph. TheCsctask didn't even appear in the top 20 task list — graph build correctly determined every project was up-to-date. Without/graph, there were still 692 Csc invocations (10.9 min cumulative), suggesting the standard mode was triggering unnecessary recompilations due to timestamp changes from the recursive traversal itself.The build succeeded cleanly with
/graph— zero errors, zero warnings. The pre-existingdotnet.Testscompilation error (RunFileTestBasenot found) that occurs without/graphdid not reproduce, likely due to different build ordering.Lower parallelism ratio is expected. The parallelism ratio dropped from 71x to 20x because there is dramatically less redundant work being scheduled across cores. The 71x ratio in the non-graph build reflects wasted parallel work (the same project references being evaluated simultaneously on multiple threads).