How to make an MSBuild Target that only runs once instead of once, before Targets that run once per framework in the TargetFrameworks tag?

后端 未结 4 1878
梦如初夏
梦如初夏 2021-02-11 07:16

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

4条回答
  •  忘了有多久
    2021-02-11 07:56

    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.

提交回复
热议问题