Monday, August 22, 2011

COPY /Y Error

Was trying to compile an application that had post build events in it and the build kept on failing. The error in a nutshell was “copy /y [path args here] exited with code 1”

 

The environment is as follows:

Windows 7 64bit

Visual Studio 2010

 

I remembered seeing this before and couldn’t recall how I fixed it:

 

The command was:

COPY /Y “$(TargetDirectory)$(TargetName).dll” “$(SolutionDir)Bin”

 

Which looks fine until you realise that a directory reference is going to expand to include the trailing “”

 

So the above command would output

COPY /Y “ctempmy.dll” “c:myothertempBin”

 

Notice the double slashes? Well I did, so changing the command to:

COPY /Y “$(TargetDirectory)$(TargetName).dll” “$(SolutionDir)Bin”

 

Which produces

COPY /Y “ctempmy.dll” “c:myothertempBin”

 

And everything started playing nicely again.

No comments:

Post a Comment