The command xcopy ... exited with code 9009 in Visual Studio

HelloWorld picture HelloWorld · May 24, 2013 · Viewed 13.3k times · Source

When I build my solution with 10 Projects I get Build failures for 7 projects. All 10 Projects have post-build events. Even those who build use an xcopy command. I say this because my colleague was the opinion VS 2012 and xcopy is not that good...

These 7 build failures did not happen before.

The following error happens when I try to build the project or "from time to time" when I start my Visual Studio.

I get this error:

Error   1   The command "xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Client" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\Client\" /s /e /v
xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Content" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\Content\" /s /e /v
xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Views" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\Views\" /s /e /v

xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\web.config" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\"
xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\global.asax" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\"

xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Tools" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\..\Tools\" /s /e /v
" exited with code 9009.    Swan.Replaced.Mobile.Web

I have googled a lot on SO and the main cause for this problem seem to be:

1.) A whitespace in the path/folder name
2.) The command does not get full paths
3.) Maybe some environment/system variables problem?

I can not see this error in my post-build event:

xcopy /y "$(ProjectDir)Client" "$(TargetDir)..\Client\" /s /e /v
xcopy /y "$(ProjectDir)Content" "$(TargetDir)..\Content\" /s /e /v
xcopy /y "$(ProjectDir)Views" "$(TargetDir)..\Views\" /s /e /v
xcopy /y "$(ProjectDir)web.config" "$(TargetDir)..\"
xcopy /y "$(ProjectDir)global.asax" "$(TargetDir)..\"
xcopy /y "$(ProjectDir)Tools" "$(TargetDir)..\..\Tools\" /s /e /v

My TargetDir is this outputpath:

..\build\web\bin\

My ProjectDir is this:

D:\Replaced\branches\ReplacedTest

comment: When I use xcopy on the console window thats totally fine.

These are my specs:

  • Windows 7 (64bit)
  • Visual Studio 2012 Premium

What I have tried to fix the issue:

  • Rebuild solution
  • Clean solution
  • wipe outputpath data
  • reboot computer
  • bite in the desktop

Nothing helped :/

Anyone can help please to spot the error? Thanks!

Answer

Ivica picture Ivica · May 27, 2013

xcopy is usually located in C:\Windows\system32 so in order for VS to see xcopy this path should be in your PATH environment variable. You can check this by running:

echo %path%

in command line and you should see path to xcopy alongside other folders...