Tuesday 30 November 2010

MSBuild and recursive copying

If you require to copy files and folder recursively, you'll need to use the following code.

First declare the list of files to copy in an ItemGroup

<ItemGroup>
  <Files Include=".\**\*.cs" />
</ItemGroup>

Then use the files metadata to perform the copy.

<copy DestinationFiles="@(Files)->'location\%(RecursiveDir)%(Filename)%(Extension)')" SourceFiles="@(Files)" />

More information available at MSBuild Team Blog article

No comments: