Friday, July 8, 2016

xcopy error - Invalid path 0 files copied

I was configuring a post build step to copy some files to the output directory of an other project. This was the XCOPY command I came up with:

XCOPY /E /Y “$(TargetDir)” “$(SolutionDir)\SecondApp\$(OutDir)”

Looks OK, right? But when I executed it, it failed with the following error message:

C:\projects\test>xcopy /E /Y "C:\projects\test\FirstApp\bin\Debug\" "C:\projects\test\SecondApp\bin\Debug\"

Invalid path

0 File(s) copied

These paths doesn’t look invalid. Strange! 

StackOverflow brought a solution; http://stackoverflow.com/questions/25840861/invalid-path-0-files-copied-error-while-using-xcopy-command.  Adding an ending dot to the source path should do the trick:

XCOPY /E /Y “$(TargetDir).” “$(SolutionDir)\SecondApp\$(OutDir)”

And indeed:

C:\projects\test>xcopy /E /Y "C:\projects\test\FirstApp\bin\Debug" "C:\projects\test\SecondApp\bin\Debug\"

C:\projects\test\AppDomainIsolationTest\SecondApp\bin\Debug\FirstApp.exe

C:\projects\test\AppDomainIsolationTest\SecondApp\bin\Debug\FirstApp.exe.config

C:\projects\test\AppDomainIsolationTest\SecondApp\bin\Debug\FirstApp.pdb

3 File(s) copied

1 comment:

Filip Van Bouwel said...

One more reason to use powershell and forget about cmd. :-)