【发布时间】:2013-05-14 00:42:56
【问题描述】:
我需要将一系列步骤联系在一起,包括构建解决方案、项目和使用自定义 MSBuild 文件运行 .cmd 文件。
下面是我的第一关:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<Exec Include="" Command="CALL GetFiles.cmd"/>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
<Exec Command="CALL final.cmd"/>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="@ProjectOutputs"/>
</Target>
</Project>
这导致错误,因为 Exec 元素位于错误的位置。
基本上,我需要构建 solution1.sln、solution2.sln、helper1.csproj 和 helper2.sln(按顺序),然后运行文件 GetFiles.cmd,然后构建 prod.wixproj,然后运行 final.cmd文件。
我看过 MSDN(here、here、here)、a blog,并浏览过各种 stackoverflow 问题(包括this、this、this、this) ,但他们都没有完全解决我想要做的事情。这是我第一次使用 MSBuild,所以我可能错过了一些东西。将不胜感激任何指针...
【问题讨论】:
-
您可以使用目标来控制构建解决方案的顺序。 msdn.microsoft.com/en-us/library/vstudio/ee216359.aspx
-
@NickCarlson 谢谢。但是如何将 ItemGroup 链接到 Target?
-
ItemGroup 也可以是 Target 的子节点。每个目标都可以有它自己负责的项目组。您可以在
级别指定构建顺序,或通过 级别的各种 *Targets 属性。 (下)
标签: visual-studio-2012 msbuild msbuild-task msbuild-propertygroup msbuild-target