Braces break %(RecursiveDir) in MSBuild

Update: 3 December 07 – The RTM version of MSBuild 2008 fixes this issue!


  • If braces ‘()’ are in the source path of a file copy operation that uses %(RecursiveDir), then the contents are copied to the root of the destination with no folder structure maintained.


  • This affects MSBuild 2005 & MSBuild 2008 (3.5) Beta 1 & Beta 2


  • Run the following on VS 2005 (add ToolsVersion=”3.5″ if running on VS2008)

<Project DefaultTargets=”DeployFiles” xmlns=”″>
              <FilesToCopy Include=”C:\Debug\SomeFolder\**\*.*”>
              <FilesToCopy Include=”C:\Debug (bug)\SomeFolder\**\*.*”>
       <Target Name=”DeployFiles”>
              <Copy SourceFiles=”%(FilesToCopy.Identity)” DestinationFolder=”%(FilesToCopy.Destination)\%(RecursiveDir)”/>

  • The path without braces copies correctly and maintains folder structure.
  • The path with braces places all files into the root destination folder.
  • Use exec and call out to xcopy
  • Write you own copy task!

Hopefully this gets fixed in Beta 2…


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s