.vcxproj中的Postbuild事件

时间:2011-11-28 22:23:50

标签: visual-studio-2010 visual-c++ visual-studio-2008 msbuild

我正在尝试对.props

中的.vcxproj文件进行postbuild事件引用

PostBuildEvent标记之间适合哪些元素?

虽然它无效但我正在寻找这样的东西:

<ItemGroup>
 <PostBuildEvent>  
  <ProjectReference Include="default.props">
  </ProjectReference>
 </PostBuildEvent>
</ItemGroup> 

1 个答案:

答案 0 :(得分:0)

我认为您不能在事件中包含.props文件。在ItemGroup之外包含您想要的props文件。 For example

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
  <Import Project="$(VCTargetsPath)\default.props" />
</Project>

在道具文件中,您可以定义PostBuildEvent:

<ItemGroup>
 <PostBuildEvent>  
  <Command>copy $(ProjectDir)$(Configuration)\$(TargetFileName) $(ProjectDir)$(Configuration)\copyOfMyproject.exe</Command>
  <Message>Making a copy of myproject.exe</Message>
 </PostBuildEvent>
</ItemGroup> 

以上示例来自How to: Use Build Events in MSBuild Projects。请注意,您可能需要在道具文件的PropertyGroup中设置PostBuildEventUseInBuild项。