Every now and then when I build my solution here (with 7 projects in it) I get the dreaded \'Command copy exited with code 4\' error, in Visual Studio 2010 Premium ed.
In my case my $(OutDir)
was simply ..\..\Build\
i.e. some relative path. And, when I was trying to xcopy as follows
xcopy /y "$(OutDir)Proj1.dll" "Anypath\anyfolder\"
I was getting the exit code error 4.
What's happening was, this command was getting executed in the $(OutDir) (in my case build folder) itself and not the directory where the csproj file of the project was located (as we would normally expect). Hence, I kept getting File not found
error (corresponding to exit code 4).
I couldn't figure this out until I wrote cd
in the Post Build events, to print which directory this was getting executed in.
So, to summarize, if we're wishing to copy
/ xcopy
files from the $(OutDir)
, either use "$(TargetDir)"
(which is complete path for output directory) or need not specify any path at all.