Msbuild根据目标参数列表复制到多个位置?

Bor*_*ens 7 msbuild copy msbuild-task msbuild-propertygroup

我有一个我想要复制到多个位置的目录.

说我有

  • home.aspx

我想把它复制到

  • ABC/home.aspx
  • 高清/ home.aspx
  • GHI/home.aspx

所以我有两个问题:

  • 如何定义列表abc,def,ghi?
  • 如何使用此列表的每个元素执行我的复制任务?

Vac*_*ano 9

这是一个实际的例子,我把它放在一起,显示你在寻找什么:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Test" ToolsVersion="3.5">

  <!--Declare an ItemGroup that points to your file you want to copy.-->
  <ItemGroup>
    <ItemToCopy Include=".\Home.aspx" />
  </ItemGroup>

  <!--Declare an ItemGroup that points to your destination Locations-->
  <ItemGroup>
    <DestLocations Include=".\abc\home.aspx" />
    <DestLocations Include=".\def\home.aspx" />
    <DestLocations Include=".\ghi\home.aspx" />
  </ItemGroup>

  <Target Name="CopyFiles">
    <!--Run the copy command to copy the item to your dest locations-->
    <!--This is where the magic happens.  The % sign before the DestLocations reference says to use
    Batching.  So Copy will be run for each unique FullPath MetaData in the DestLocations ItemGroup.-->
    <Copy SourceFiles="@(ItemToCopy)" DestinationFolder="%(DestLocations.FullPath)" />
  </Target>
</Project>
Run Code Online (Sandbox Code Playgroud)