我有一个 msbuild proj 文件,如下所示。
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Demo">
<ItemGroup>
<AllFiles Include="src\**\*" ></SrcFiles>
</ItemGroup>
<PropertyGroup>
<DestFolder>copy\</DestFolder>
</PropertyGroup>
<ItemGroup>
<Transform01
Include="@(AllFiles >'$(DestFolder)%(RecursiveDir)%(Filename)%(Extension)')" />
</ItemGroup>
<Target Name="Demo">
<Message Text="%40(Transform01):" Importance="high" />
<Message Text="@(Transform01)" />
<Message Text="===== Copying files =====" Importance="high" />
<Copy SourceFiles="@(AllFiles)" DestinationFiles="@(Transform01)" />
<Copy SourceFiles="@(AllFiles)" DestinationFiles="@(AllFiles >'$(DestFolder)%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
</Project>
上述目标中指定的两次复制过程抛出错误如下第一次复制抛出错误如下
(error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 14 item(s). They must have the same number of items.)
第二个副本抛出错误如下
error MSB3021: Unable to copy file "..\Data\Files\dll\1.dll" to "@(AllFiles >'copy\dll\1.dll')".Illegal characters in path.
但是,如果我编写如下所示的复制过程,复制将不会出错
<Copy SourceFiles="@(AllFiles)" DestinationFiles="$(DestFolder)%(RecursiveDir)%(Filename)%(Extension)" />
为什么会这样?