Command copy exited with code 4 when building - Visual Studio restart solves it

前端 未结 27 2311
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 08:51

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.

27条回答
  •  [愿得一人]
    2020-12-04 09:11

    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.

提交回复
热议问题