Recursively copy to output in msbuild project

I have this very specific need to copy all files and folders from a source folder, to the project build output, akin to xcopy. Here’s an AfterBuild target that does that.

  <Target Name="AfterBuild">
      <HtmlContentSource Include="..\html\**\*.*" Exclude="Web.config"/>
    <Message Text="### Copy HTML content ###" Importance="high" />
        DestinationFiles="@(HtmlContentSource -> '$(OutputPath)\html\%(RecursiveDir)%(Filename)%(Extension)')"

It uses MSBuild transforms.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s