【问题标题】:Multiple BeforeBuild targets多个 BeforeBuild 目标
【发布时间】:2022-11-03 00:35:05
【问题描述】:

我想创建两个不同的 nuget 包,以便在我的项目中制作一些预构建的东西。与 NuGet 包关联的自定义目标文件都有一个 BeforeBuild 目标:

<Target Name="BeforeBuild">
   <Exec Command='...' />
</Target>

我注意到 BeforeBuild 目标只执行一次,这听起来是正确的,但在我的场景中,我希望包添加两个预构建步骤,如何解决问题?

谢谢

【问题讨论】:

    标签: msbuild nuget


    【解决方案1】:

    您应该定义多个不同名称的目标,这些目标挂钩到构建阶段(使用BeforeTargets 挂钩),而不是覆盖BeforeBuild 目标:

    <Target Name="MyCustomTarget" BeforeTargets="BeforeBuild">
       <Exec Command='...' />
    </Target>
    

    有关执行顺序的更多详细信息,请参阅Target build order documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-21
      • 2021-03-07
      • 2017-10-10
      • 1970-01-01
      • 2011-03-22
      • 2020-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多