I am creating an MSBuild v4 task that happens to need to call the Copy task to recursively copy some files (without flattening the directory structure at the destination).
I have come up with:
var copy = new Microsoft.Build.Tasks.Copy
{
BuildEngine = this.BuildEngine,
SourceFiles = new ITaskItem[] { new TaskItem(@"C:\source\**\*.foo") },
DestinationFolder = new TaskItem(@"c:\dest\\")
};
copy.Execute();
but am getting an error 'Could not copy C:\source\**\*.foo to c:\dest\* - Illegal characters in path'
There doesn't seem to be much online help for pragmatic invocation, and have drawn a blank. Any ideas?
Thanks
Jon
It looks like the Copy task doesn't have an intrinsic understanding of recursion; the following code would cause the Copy task to be invoked once per file level, and this is handled by the MSBuild runner.
<ItemGroup>
<x Include="c:\source\**\*.foo" />
</ItemGroup>
<Copy SourceFiles="@(x)" DestinationFolder="c:\dest\%(RecursiveDir)" />
However, since the Copy task seems to treat SourceFiles and DestinationFiles as an associative array (each of type ITaskItem[]), we just performed a recursive descent and built up these two arrays manually, before execing it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With