[fix] Fix MsCoverageReferencedPathMaps: skip during design-time builds and parallelize project builds#16043
[fix] Fix MsCoverageReferencedPathMaps: skip during design-time builds and parallelize project builds#16043nohwnd wants to merge 1 commit into
Conversation
…add BuildInParallel - Add 'DesignTimeBuild' != 'true' condition to MsCoverageReferencedPathMaps target to prevent it from running during IDE design-time builds (fixes #15105). Design-time builds are frequent background builds triggered by VS for IntelliSense/code analysis, and running MSBuild on all referenced projects during each of these builds causes significant IDE slowdowns. - Add BuildInParallel="true" to the MSBuild task to parallelize the invocation across referenced projects, reducing build times for solutions with many dependencies (partial fix for #15295). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes IDE slowdowns caused by MsCoverageReferencedPathMaps running on every design-time build, and improves performance for real builds by parallelizing referenced project invocations.
Changes:
- Skip the
MsCoverageReferencedPathMapstarget when$(DesignTimeBuild)istrue. - Enable
BuildInParallel="true"on theMSBuildtask for referenced projects.
nohwnd
left a comment
There was a problem hiding this comment.
Review Summary
Dimensions activated: Build Script & Infrastructure Hygiene, Dependency & Package Integrity, Cross-TFM & Framework Resolution
Both changes are correct and follow established MSBuild patterns:
DesignTimeBuildguard: canonical SDK pattern; no behavioral change during real builds.BuildInParallel="true": MSBuild batching on%(NearestTargetFramework)still applies correctly per TFM. The invoked target is read-only metadata, so no inter-project hazard. Output item ordering is non-deterministic with parallelism, but source root path maps are an unordered set — downstreamPathMapcompiler arg is not order-sensitive.
No correctness, compatibility, or resource management issues found.
🧠 Reviewed by Expert Code Reviewer
🧠 Reviewed by Expert Code Reviewer 🧠
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Warning The 🔧 Branch updated — SDK bump applied Updated The code change (2-line
|
🤖 This is an automated fix generated by GitHub Copilot.
Closes #15105
Partial fix for #15295
Root Cause
The
MsCoverageReferencedPathMapstarget inMicrosoft.CodeCoverage.targetsran unconditionally on everyCoreCompileinvocation, including during IDE design-time builds. Design-time builds happen frequently in the background while you type in Visual Studio (for IntelliSense, error squiggles, etc.) and are triggered far more often than real builds. RunningMSBuildon all referenced projects on every design-time build caused significant IDE slowdowns — especially for solutions with large project graphs.Additionally, the
MSBuildtask invoked referenced projects sequentially (one at a time, batched by TFM), even though the individual project invocations are independent.Fix
Two changes to
Microsoft.CodeCoverage.targets:Skip during design-time builds — Added
'$(DesignTimeBuild)' != 'true'to theMsCoverageReferencedPathMapstarget condition. The SDK sets$(DesignTimeBuild)totrueduring all IDE background build invocations; this is the standard pattern used across the MSBuild ecosystem (e.g., Roslyn analyzers, source generators) to avoid expensive work during design-time passes.Parallelize project invocations — Added
BuildInParallel="true"to theMSBuildtask. This allows the build engine to invoke theInitializeSourceRootMappedPaths/MsCoverageGetPathMaptarget on multiple referenced projects concurrently, reducing wall-clock time for large project graphs.Testing
This is a
.targetsfile change (MSBuild metadata, no C# code). There are no automated tests for this specific target behavior in the repo. The change follows the established SDK pattern for skipping work during design-time builds and is a minimal, low-risk addition to an existing condition.