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 1879
梦如初夏
梦如初夏 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 08:15

    On single target framework I only use BeforeTargets="PreBuildEvent":

    
      
        netstandard2.0
      
      
        
      
    
    

    on multi target frameworks I use BeforeTargets="DispatchToInnerBuilds"

    
      
        netstandard2.0;net461
      
      
        
      
    
    

    So my custom command is only exeuted once before every build. If you use InitialTargets, the command is executed more often than only once! For example if you save your project!

提交回复
热议问题