命令xcopy ...在Visual Studio中以代码9009退出

Hel*_*rld 4 build build-error post-build-event visual-studio-2012

当我用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
Run Code Online (Sandbox Code Playgroud)

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

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

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

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
Run Code Online (Sandbox Code Playgroud)

我的TargetDir是以下输出路径:

..\build\web\bin\
Run Code Online (Sandbox Code Playgroud)

我的ProjectDir是这样的:

D:\Replaced\branches\ReplacedTest
Run Code Online (Sandbox Code Playgroud)

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

这些是我的规格:

  • Windows 7(64位)
  • Visual Studio 2012专业版

我试图解决的问题:

  • 重建解决方案
  • 清洁溶液
  • 擦除输出路径数据
  • 重新启动电脑
  • 咬在桌面上

什么都没有帮助:/

任何人都可以帮助您发现错误吗?谢谢!

小智 5

通常位于xcopy中C:\Windows\system32,以便VS看到xcopy时,此路径应位于PATH环境变量中。您可以通过运行以下命令进行检查:

echo %path%
Run Code Online (Sandbox Code Playgroud)

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