当我用 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 时完全没问题。
这些是我的规范:
我试图解决的问题:
没有任何帮助:/
任何人都可以帮忙找出错误吗?谢谢!
最佳答案
xcopy 通常位于 C:\Windows\system32
中,所以为了让 VS 看到 xcopy,这个路径应该在你的 PATH 环境变量中。您可以通过运行来检查:
echo %path%
在命令行中,您应该看到 xcopy 的路径以及其他文件夹...