I have a code generator tool that I partially own, and now that csproj files can list multiple Target Frameworks in them and building builds all of them, I am trying to figure o
While some targets only run in the inner builds, e.g. when you use BeforeTargets="BeforeBuild"
, the outer build also defines the IsCrossTargetingBuild
variable to indicate that the currently running build is the outer build which dispatches to the inner build and is the preferred way to condition targets.
So you can condition your target like Condition="'$(IsCrossTargetingBuild)' == 'true'"
to make sure the target is only run for the outer build.