2

I have a console program that outputs its exe & dlls to a specified directory.

As a post build event I am trying to copy everything in that directory to another directory.

My xcopy command works from command prompt but fails in VS2010? How can this be?

I am testing it by going to the project folder and executing the following in command prompt. (it is the output from VS2010)

In my post-build event:

xcopy "$(OutDir)*.*" "$(TargetDir)..\..\Foo\Bar\" /s /y /i

From command prompt I am executing the following which works.

xcopy "..\..\..\..\MyDir\baz\zip\*.*" "c:\1\2\3\MyDir\baz\zip\..\..\Foo\Bar\" /s /y /i

Sorry about the directory names.

End result should be two directories with the same files in them:

c:\1\2\3\MyDir\baz\zip
c:\1\2\3\MyDir\foo\bar 

The target path is relative to the output directory.

When its executed as part of the build it gives an exit code 4

Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.

Where am I going wrong?

2
  • You might to replace xcopy with a xcopy.bat that you write which logs parameters and results to see whats going on Jan 17, 2013 at 2:20
  • 1
    out of curiosity, if you replace the relative paths with absolute paths, does it work? Jan 17, 2013 at 2:21

2 Answers 2

2

Got it,

I changed the xcopy command in my post build event to:

xcopy "$(TargetDir)*.*" "$(TargetDir)..\..\Foo\Bar\" /s /y /i

The executed result being:

xcopy "c:\1\2\3\MyDir\baz\zip\*.*" "c:\1\2\3\MyDir\baz\zip\..\..\Foo\Bar\" /s /y /i

Which VS2010 much preferred, I guess you can't use a relative path without a base path.

1

Why you don'y call batch file which will run xcopy for required files source to destination?

call "$(SolutionDir)scripts\copyifnewer.bat"

With copyifnewer.bat looking like this:

IF NOT EXIST <destination> md <destination>
XCOPY /Y <file> <destination>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.