Skip to content

Conditionally skipped targets may lead to bad performance of a build. #11753

Open
@AR-May

Description

@AR-May

Description

When building a project:

  • If a target is skipped due to a condition during the project's build, and
  • Other projects depend on this target (commonly an initial target)

This situation can cause delays in the build process for dependent projects.

Symptoms

  • Significant variance in build times between builds.
  • MSBuild tasks show inconsistent performance between builds.
  • When switching to graph build mode, MSBuild tasks take considerably longer to resolve than expected (they should normally resolve almost immediately).

Technical details

When the initial target of a project (or another target necessary for a dependent project's build) is skipped due to a condition:
-The ResultsCache does not resolve this target in the main node when the build results are requested by a dependent project.
-Instead, the project is rescheduled to build the skipped target again. It waits in the queue for a build node, and if the condition still evaluates to false, the node resolves the target immediately with the same "skipped" result.
-If the build node is occupied, this can lead to delays in the overall build process.
For more details, refer to #11637.

Fix

To address this issue:

  1. Check for conditional targets on which dependent projects rely (e.g., conditional initial targets).
  2. If such targets are found, consider:
    • Removing the condition, or
    • Removing the dependency link from this target.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions