msbuildtasks icon indicating copy to clipboard operation
msbuildtasks copied to clipboard

Robocopy fails when Options property contains more than one option

Open Spiralis opened this issue 11 years ago • 0 comments

I have this in my project file:

<RoboCopy 
  SourceFolder="C:\Source" 
  DestinationFolder="C:\Destination" 
  SourceFiles="*.*" 
  Options="/R:5 /W:5" />

When building it generates the following command and response:

C:\WINDOWS\SYSTEM32\robocopy.exe C:\Source\ C:\Destination\ "*.*" /NP "/R:5 /W:5"
...
ROBOCOPY : error : Invalid Parameter #5 : "/R:5 /W:5"

On the other hand, if I change it to this:

<RoboCopy 
  SourceFolder="C:\Source" 
  DestinationFolder="C:\Destination" 
  SourceFiles="*.*" 
  Options="/R:5" />

Then during build it yields no errors. The command output is:

C:\WINDOWS\SYSTEM32\robocopy.exe C:\Source\ C:\Destination\ "*.*" /NP /R:5

It seems that the expanded options are quoted when the Options property contains whitespace. Quoting makes sense for file arguments, but the Options property may hold multiple options and should not have been quoted, IMHO.

Spiralis avatar Oct 27 '14 00:10 Spiralis