Prebuild event Copy command exits with code 1

Mark Bostleman picture Mark Bostleman · Apr 8, 2012 · Viewed 51.3k times · Source

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?

Answer

Michael Bowersox picture Michael Bowersox · Apr 8, 2012

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\"