can someone explain the differences between these:
<Target Name="AfterBuild">
<!-- task here -->
</Target>
and:
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)\..\lib\$(PlatformName)\x.dll" .</PostBuildEvent>
</PropertyGroup>
Thank you.
Both PostBuildEvent and AfterBuild are MSBuild targets. The difference between the two is the conditions around when they are invoked
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,
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.
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.
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.