VS2010 MSBuild目标仅在重建时运行



我目前正在尝试构建一个c++库,我想要的是,每次构建按钮被按下,我会得到所有的包含文件被移动到某个目录。

我现在拥有的是这个

<Target Name="CopyToIncludeFiles">
  <Message Text="Copying All '*.h' and '*.hpp' to the include directory" Importance="high">
  </Message>
  <Copy SourceFiles="@(ClInclude)" DestinationFolder="..HelperLibx86include">
  </Copy>
</Target>

我将目标包含在DefaultTargets like中所以

<Project ToolsVersion="4.0" DefaultTargets="Build;CopyToIncludeFiles;" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

只要我使用重建,这一切都工作得很好,但是当我刚刚点击构建时,它永远不会运行。

无论我点击构建还是重建,我需要做些什么来运行这个?

我认为你解决的任务更容易在项目属性中使用PreBuild Event,因为它只是简单的命令行命令。

如果你仍然想要msbuild -你可以这样使用BeforeTargets:

<Target Name="CopyToIncludeFiles" BeforeTargets="Rebuild;Build">
  <Message Text="Copying All '*.h' and '*.hpp' to the include directory" Importance="high" />
  <Copy SourceFiles="@(ClInclude)" DestinationFolder="..HelperLibx86include"  />
</Target>

您不应该更改项目DefaultTargets属性以包含您的任务。

还请注意,如果您的项目代码不需要重新编译(即没有更改cpp/h文件),PreBuild事件和此msbuild任务将不会运行

最新更新