【问题标题】:The command xcopy ... exited with code 9009 in Visual Studio命令 xcopy ... 在 Visual Studio 中以代码 9009 退出
【发布时间】:2013-05-24 08:48:51
【问题描述】:

当我使用 10 个项目构建解决方案时,我发现 7 个项目的构建失败。所有 10 个项目都有构建后事件。即使是那些构建的人也使用 xcopy 命令。我这么说是因为我的同事是 VS 2012 的意见,而 xcopy 不是那么好......

这 7 次构建失败以前没有发生过。

当我尝试构建项目或启动 Visual Studio 时“不时”发生以下错误。

我收到此错误:

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

我在 SO 上搜索了很多,导致这个问题的主要原因似乎是:

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

我在构建后事件中看不到此错误:

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

我的 TargetDir 是这个输出路径:

..\build\web\bin\

我的项目目录是这样的:

D:\Replaced\branches\ReplacedTest

评论:当我在控制台窗口上使用 xcopy 时,这完全没问题。

这些是我的规格:

  • Windows 7(64 位)
  • Visual Studio 2012 高级版

我尝试解决的问题:

  • 重建解决方案
  • 清洁解决方案
  • 擦除输出路径数据
  • 重启电脑
  • 咬桌面

没有任何帮助:/

谁能帮忙找出错误?谢谢!

【问题讨论】:

标签: visual-studio-2012 build post-build-event build-error


【解决方案1】:

xcopy 通常位于C:\Windows\system32,所以为了让 VS 看到 xcopy,这个路径应该在你的 PATH 环境变量中。您可以通过运行来检查:

echo %path%

在命令行中,您应该会在其他文件夹旁边看到 xcopy 的路径...

【讨论】:

    【解决方案2】:

    我刚刚在 xcopy 命令前面添加了 C:\Windows\System32\,它解决了问题。同时,还要检查您是否没有在意外中出现一些额外的换行符。但是,如果您愿意,您也可以将系统目录添加回您的 Windows 路径。您可以在计算机 - 属性 - 高级系统设置 - 环境变量 - 系统变量 - 路径中找到它。

    例如:

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

    P.S 原贴在这里:https://ict.ken.be/xcopy-exit-with-code-9009-in-visual-studio-post-build

    【讨论】:

    • 您也可以将 C:\Windows 路径替换为 %SYSTEMROOT%。
    猜你喜欢
    • 1970-01-01
    • 2010-12-31
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    • 2012-10-24
    相关资源
    最近更新 更多