Skip to content

[BuildCheck Suggestion]: Detect use of Exec task to run "dotnet build" or similar commands #11125

@dsplaisted

Description

@dsplaisted

Summary

We should warn when an Exec task is used to spawn a new build via dotnet build, dotnet publish, etc.

Background and Motivation

It's usually a bad pattern to run dotnet build, dotnet publish, etc from an Exec task, since this spawns an entirely separate build that the MSBuild engine doesn't have visibility over. We should recommend using an MSBuild task instead.

Sample issue or antipattern that the check should be flagging

  <Target Name="BuildVer2022">
    <Exec Command="dotnet build -p:C3DVersion=Ver2022 -c $(Configuration)"/>
  </Target>

Source: dotnet/sdk#45034 (comment)

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'backloghelp wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.internal-team-onboardingtriaged

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions