xcopy is not recognized as an internal or external command, operable program or batch file

Alk picture Alk · Jun 24, 2013 · Viewed 59.2k times · Source

I have a problem using 'xcopy' command.

I'm building a C# project with msbuild. At the end of the build, a batch file is called to copy my assemblies from Debug/Release to some other folders.

Here is the problem, my build fail and the error log is 'xcopy is not recognized as an internal or external command, operable program or batch file'.

The path is correctly set, xcopy do works from a windows command line and from the visual studio command line (the one set with the project environment).

I tried to set the path in the batch file but it doesn't help.

Any suggestion?

I'm using windows 7

Cheers :)

Answer

Avalanchis picture Avalanchis · Jul 16, 2013

I encountered the same problem.

It seems to be a problem with the path environment variable within Visual Studio.

When I added a "path" statement to the beginning of my build event, it produced the following output:

PATH=

This seems to indicate that the path is empty within the VS build environment.

When I specify the full path to xcopy like this, the problem went away:

%systemroot%\System32\xcopy ...

I'm not sure what caused Visual Studio to lose it's path.