Skip to content

[fix] Fix MsCoverageReferencedPathMaps: skip during design-time builds and parallelize project builds#16043

Open
nohwnd wants to merge 1 commit into
mainfrom
fix/issue-15105-db6d4a4c32349aa6
Open

[fix] Fix MsCoverageReferencedPathMaps: skip during design-time builds and parallelize project builds#16043
nohwnd wants to merge 1 commit into
mainfrom
fix/issue-15105-db6d4a4c32349aa6

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented May 18, 2026

🤖 This is an automated fix generated by GitHub Copilot.

Closes #15105
Partial fix for #15295

Root Cause

The MsCoverageReferencedPathMaps target in Microsoft.CodeCoverage.targets ran unconditionally on every CoreCompile invocation, 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. Running MSBuild on all referenced projects on every design-time build caused significant IDE slowdowns — especially for solutions with large project graphs.

Additionally, the MSBuild task 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:

  1. Skip during design-time builds — Added '$(DesignTimeBuild)' != 'true' to the MsCoverageReferencedPathMaps target condition. The SDK sets $(DesignTimeBuild) to true during 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.

  2. Parallelize project invocations — Added BuildInParallel="true" to the MSBuild task. This allows the build engine to invoke the InitializeSourceRootMappedPaths/MsCoverageGetPathMap target on multiple referenced projects concurrently, reducing wall-clock time for large project graphs.

Testing

This is a .targets file 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.

🔍 Triaged by Issue Repro Triage & Auto-Fix 🔍

🔍 Triaged by Issue Repro Triage & Auto-Fix 🔍

…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>
Copilot AI review requested due to automatic review settings May 18, 2026 14:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MsCoverageReferencedPathMaps target when $(DesignTimeBuild) is true.
  • Enable BuildInParallel="true" on the MSBuild task for referenced projects.

Copy link
Copy Markdown
Member Author

@nohwnd nohwnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Dimensions activated: Build Script & Infrastructure Hygiene, Dependency & Package Integrity, Cross-TFM & Framework Resolution

Both changes are correct and follow established MSBuild patterns:

  • DesignTimeBuild guard: 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 — downstream PathMap compiler arg is not order-sensitive.

No correctness, compatibility, or resource management issues found.


🧠 Reviewed by Expert Code Reviewer

🧠 Reviewed by Expert Code Reviewer 🧠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MsCoverageReferencedPathMaps runs during design-time build

2 participants