Prebuild event Copy command exits with code 1

pre-build-eventvisual-studio-2010

I have the following in a prebuild event:

copy /y $(ProjectDir)ThirdPartyAssemblies\ $(TargetDir)

Which results in the following error:

The command "copy /y C:\Users\myusername\Documents\Visual Studio 2010\Projects\mysolution\myproject\ThirdPartyAssemblies* C:\Users\myusername\Documents\Visual Studio 2010\Projects\mysolution\myproject\bin\Debug\" exited with code 1.

I've tried it in a post build event too and get the same error. Yet when I run the command it results in (the one in the error) in a console window it works fine. What am I doing wrong?

Best Solution

I'm not sure if it's related to the error you're receiving, but you need to place quotes around your path/file names since there are spaces in them.

copy /y "C:\Users\myusername\Documents\Visual Studio 2010\Projects\mysolution\myproject\ThirdPartyAssemblies*" "C:\Users\myusername\Documents\Visual Studio 2010\Projects\mysolution\myproject\bin\Debug\"