I have an msbuild proj file as follows.
<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>
The two copy process specified in the above target is throwing errors as follows
First copy is throwing error as follows
(error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 14 item(s). They must have the same number of items.)
The second copy is throwing error as below
error MSB3021: Unable to copy file "..\Data\Files\dll\1.dll" to "@(AllFiles >'copy\dll\1.dll')".Illegal characters in path.
But if i write the copy process as shown below copy will take place with no error
<Copy SourceFiles="@(AllFiles)" DestinationFiles="$(DestFolder)%(RecursiveDir)%(Filename)%(Extension)" />
Why this is happening?
You may be missing a – character in your transforms.
The following should also work.
Source: http://msdn.microsoft.com/en-us/library/3e54c37h.aspx