Msbuild 根据目标参数列表复制到多个位置? [英] Msbuild copy to several locations based on list of destination parameter?
本文介绍了Msbuild 根据目标参数列表复制到多个位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个想要复制到多个位置的目录.
I got a directory I want to copy to a number of locations.
说我有
- home.aspx
我想复制到
- abc/home.aspx
- def/home.aspx
- ghi/home.aspx
我有两个问题:
- 如何定义列表 abc、def、ghi?
- 如何使用此列表的每个元素执行我的复制任务?
推荐答案
这是我整理的一个实际示例,它显示了您正在寻找的内容:
Here is an actual example that I put together that shows what you were looking for:
<?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=".abchome.aspx" />
<DestLocations Include=".defhome.aspx" />
<DestLocations Include=".ghihome.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>
这篇关于Msbuild 根据目标参数列表复制到多个位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文