MSBuild-将ItemGroup保留在单独的文件中
我有以下MSBuild目标正在工作MSBuild-将ItemGroup保留在单独的文件中,msbuild,Msbuild,我有以下MSBuild目标正在工作 <Target Name="MyTarget"> <ItemGroup> <ExcludeList Include="$(ProjectPath)\**\.svn\**"/> <ExcludeList Include="$(ProjectPath)\**\obj\**"/> <ExcludeList Include="$(ProjectPath)\**
<Target Name="MyTarget">
<ItemGroup>
<ExcludeList Include="$(ProjectPath)\**\.svn\**"/>
<ExcludeList Include="$(ProjectPath)\**\obj\**"/>
<ExcludeList Include="$(ProjectPath)\**\*.config"/>
<ExcludeList Include="$(ProjectPath)\**\*.cs"/>
<ExcludeList Include="$(ProjectPath)\**\*.csproj"/>
<ExcludeList Include="$(ProjectPath)\**\*.user"/>
</ItemGroup>
<ItemGroup>
<ZipFiles Include="$(ProjectPath)\**\*.*" Exclude="@(ExcludeList)" />
</ItemGroup>
<Zip Files="@(ZipFiles)"
WorkingDirectory="$(ProjectPath)"
ZipFileName="$(PackageDirectory)\$(ProjectName).package.zip"
ZipLevel="9" />
</Target>
我希望将ExcludeList项目组存储在单独的文件中,因为我将在单独的文件中有多个msbuild目标,这些文件都需要使用该列表,并且我不希望重新创建它并维护多个副本
将项目组外部化并将其加载到多个msbuild脚本中的最佳方法是什么?在单独的msbuild文件中创建项目组,然后可以将其包含在语句中 制造目标
<Project DefaultTargets = "Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemGroup Condition="'$(ProjectPath)' != ''">
<ExcludeList Include="$(ProjectPath)\**\.svn\**"/>
<ExcludeList Include="$(ProjectPath)\**\obj\**"/>
<ExcludeList Include="$(ProjectPath)\**\*.config"/>
<ExcludeList Include="$(ProjectPath)\**\*.cs"/>
<ExcludeList Include="$(ProjectPath)\**\*.csproj"/>
<ExcludeList Include="$(ProjectPath)\**\*.user"/>
<ExcludeList Include="$(ProjectPath)\**\*.proj"/>
</ItemGroup>
</Project>
@我试过了。当我将ItemGroup元素移动到单独的文件中,然后使用Import时,ExcludeList属性在原始目标中为空。你能在回答中加入一个工作样本吗?@Hussom谢谢。那个样品对我有用。现在要弄清楚为什么在我的实际脚本中它不起作用…@Hussom,我把它都用上了。我记不清到底是什么问题,但它与正确限定所有路径有关。
<Project DefaultTargets = "Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<PropertyGroup>
<ProjectPath>D:\Temp</ProjectPath>
</PropertyGroup>
<Import Project=".\Make.targets" Condition="'$(ProjectPath)' != ''" />
<Target Name = "Build">
<Message Text="Exclude = @(ExcludeList)" />
</Target>
</Project>
Build started 24-01-2012 16:50:33.
Project "D:\Temp\Make.proj" on node 1 (default targets).
Build:
Exclude = D:\Temp\Make.proj
Done Building Project "D:\Temp\Make.proj" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)