Skip to content

[BuildCheck Suggestion]: Batching Copy task invocations #12884

@rainersigwald

Description

@rainersigwald

Summary

We should have a check for calls of the Copy task that are batched, instead of in a single low-overhead parallelizable invocation.

Background and Motivation

One fairly common antipattern in builds is batching when not necessary. Copy is a great example--it can inherently handle most file-copying tasks in a single invocation and uses internal parallelism to copy things quickly, but it's sometimes easier to understand a batched invocation where a single file gets copied. But then you pay a performance cost for that forever.

Sample issue or antipattern that the check should be flagging

<ItemGroup>
  <CopyInputs Include="SomeDirectory\**.txt" />
</ItemGroup>

<Target Name="BadCopyExample">
  <Copy SourceFiles="%(CopyInputs.Identity)" DestinationFolder="SomeOutput" />
</Target>

Sample output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: BuildCheckBuildCheck SuggestionSuggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck'

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions