本文介绍了PostBuildEvent 和 AfterBuild 目标之间的 Visual Studio 项目文件区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下这些之间的区别:

can someone explain the differences between these:

<Target Name="AfterBuild">
    <!-- task here -->
</Target>

和:

<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)..lib$(PlatformName)x.dll" .</PostBuildEvent>
</PropertyGroup>

谢谢.

推荐答案

PostBuildEvent 属性能够保存作为 Command 属性传递给 Exec 任务的命令.基本上你最终会得到一个看起来像这样的目标,

The PostBuildEvent property is able to hold a command that is passed as the Command attribute to an Exec task. Essentially you end up with a target that looks like this,

<Target Name="PostBuildEvent">
   <Exec Command="$(PostBuildEvent)" />
</Target>

您可以使用 IDE 中的设置配置运行时的条件,默认情况下它仅在成功构建时运行.

You can configure the conditions when this will be run with a setting in the IDE, by default it only runs on a successful build.

AfterBuild 目标能够包含任意 MSBuild 任务,包括一个或多个 Exec 任务或 MSBuild 可用的任何其他任务,这会增加复杂性.

The AfterBuild target is able to contain arbitrary MSBuild tasks, including one or more Exec tasks or any other task available to MSBuild, which allows for greater complexity.

就它们的执行时间而言,PostBuildEvent 目标在CoreBuild"之前运行,而AfterBuild"目标将在CoreBuild"之后运行.如果位置很重要,您可以使用 $(DependsOn..) 声明,或通过在新目标上指定 BeforeTargets 和 AfterTargets,制作自己的目标并将其连接到构建中需要它运行的任何位置.

In terms of when they are executed, the PostBuildEvent target runs just prior to "CoreBuild" while the "AfterBuild" target will run after "CoreBuild". If the placement is critical, you can make your own target and wire it into whereever in the build you need it to run, using the $(DependsOn..) declarations, or by specifying BeforeTargets and AfterTargets on your new target.

这篇关于PostBuildEvent 和 AfterBuild 目标之间的 Visual Studio 项目文件区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:24