As other answers explain, exit code 4 may have many causes.
I noticed a case, where resulting path names exceeded the maximum allowed length (just like here).
I have replaced xcopy by robocopy for the affected post build event; robocopy seems to handle paths slightly different and was able to complete the copy task that xcopy was unable to handle.