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

13,417

Solution 1

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...

Solution 2

I just added C:\Windows\System32\ in front of the xcopy command and it solved things. In mean time also check that you didn't at some additional line breaks on accident. But if you like, you can also add the system directory back to your windows path. You can find this at computer - properties - advanced system settings - environment variables - system variables - path.

So for example:

C:\Windows\System32\xcopy /s /y "$(ProjectDir)bin\ken.MojoPortal.HtmlTools.Web.dll" "$(SolutionDir)Web\bin\"

P.S Originally posted here : https://ict.ken.be/xcopy-exit-with-code-9009-in-visual-studio-post-build

Share:
13,417
HelloWorld
Author by

HelloWorld

Updated on June 28, 2022

Comments

  • HelloWorld
    HelloWorld about 2 years

    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!

  • d.i.joe
    d.i.joe over 5 years
    You can also replace the C:\Windows path with %SYSTEMROOT%.