C# 为什么 xcopy 在 Visual Studio 构建后步骤中以代码 9009 退出?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1988668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 22:26:25  来源:igfitidea点击:

Why does xcopy exit with code 9009 in Visual Studio post-build step?

c#visual-studioxcopy

提问by David Veeneman

I am getting the following error, which I don't understand. Any suggestions?

我收到以下错误,我不明白。有什么建议?

Error 1 The command "xcopy "D:\Users\johndoe\Documents\Visual Studio 2008\Projects\MyProject\MyProject.Modules.Ribbon\bin\Debug\MyProject.Modules.Ribbon.dll" "D:\Users\johndoe\Documents\Visual Studio 2008\Projects\MyProject\MyProject\bin\Debug\Modules\" /Y" exited with code 9009. MyProject.Modules.Ribbon

错误 1 ​​命令 "xcopy "D:\Users\johndoe\Documents\Visual Studio 2008\Projects\MyProject\MyProject.Modules.Ribbon\bin\Debug\MyProject.Modules.Ribbon.dll" "D:\Users\johndoe\ Documents\Visual Studio 2008\Projects\MyProject\MyProject\bin\Debug\Modules\" /Y" 退出,代码为 9009。MyProject.Modules.Ribbon

采纳答案by David Veeneman

Found my answer: The command had a line break between the source and destination strings. So, Visual Sudio was treating it as two commands. Eliminating the line break solved the problem.

找到我的答案:该命令在源字符串和目标字符串之间有一个换行符。因此,Visual Sudio 将其视为两个命令。消除换行符解决了问题。

回答by SLaks

Your xcopycommand failed for some reason.

xcopy由于某种原因,您的命令失败。

I would guess that either the DLL file doesn't exist (eg, the build failed) or the target path doesn't exist.

我猜想要么 DLL 文件不存在(例如,构建失败),要么目标路径不存在。

Run the same command line in a command prompt and see what error it prints.

在命令提示符下运行相同的命令行并查看它打印的错误。

回答by Jobrocol

I encounted this error on the TeamCity build server. I finally resolved it after checking the build log and found:

我在 TeamCity 构建服务器上遇到了这个错误。我在检查构建日志后终于解决了它,发现:

"'xcopy' is not recognized as an internal or external command."

“'xcopy' 未被识别为内部或外部命令。”

I then changed my statement to:

然后我将我的陈述改为:

C:\Windows\System32\xcopy"$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R

C:\Windows\System32\xcopy"$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R

回答by RobinG

This error can occur if your system PATH environment variable has been set incorrectly. The path should contain (at the very least)

如果您的系统 PATH 环境变量设置不正确,则会发生此错误。路径应该包含(至少)

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;

on modern versions of Windows (see https://superuser.com/questions/124239/what-is-the-default-path-environment-variable-setting-on-fresh-install-of-window). I have just found my system PATH had been set to

在现代版本的 Windows 上(参见https://superuser.com/questions/124239/what-is-the-default-path-environment-variable-setting-on-fresh-install-of-window)。我刚刚发现我的系统 PATH 已设置为

C:\Program Files (x86)\Bad Vendor\Buggy Program;

by an msi installer that obviously has issues.

由显然有问题的 msi 安装程序。

If you don't know how to edit the PATH via the System Properties dialog, check out this link : http://support.microsoft.com/kb/310519- it's basically the same in Windows 7 & 8 as it is in XP.

如果您不知道如何通过“系统属性”对话框编辑 PATH,请查看此链接:http: //support.microsoft.com/kb/310519- 在 Windows 7 和 8 中与在 XP 中基本相同.

Finally, it's worth noting that a lot of programs don't notice if you update the PATH while they are running, so closing down and re-opeing programs like Visual Studio or command prompt windows will be required for the repaired path to take effect.

最后,值得注意的是,如果您在运行时更新 PATH,许多程序不会注意到,因此需要关闭并重新打开 Visual Studio 或命令提示符窗口等程序,修复后的路径才能生效。

回答by user3875275

Restart Visual Studio. Worked for me

重新启动 Visual Studio。为我工作

回答by Mahesh Malpani

Mostly related to path C\Program files...\some.exe. It should be "C\Program files...\some.exe"

主要与路径 C\Program files...\some.exe 相关。它应该是“C\Program files...\some.exe”

回答by Manjuboyz

Even though its a old post, I found fix which may help some one.

尽管它是一个旧帖子,但我找到了可能对某些人有所帮助的修复程序。

What not helped me

什么对我没有帮助

Restarting visual studio.
Restarting computer
tried few steps as above and few more blogs

I am using Visual Studio 2013.

我正在使用 Visual Studio 2013。

What helped me.

什么帮助了我。

Check the Environmental Variablescheck the PATH, does it has all or nothing or only a part.

检查环境变量,检查 PATH,它是全部还是没有,还是只有一部分。

since I was having backup of System PATH, I just copy-pasted the variables Under

因为我有系统路径的备份,我只是复制粘贴下的变量

System Variables -> Path.

At last, I gave rebuild to the project voila! it worked for me.

最后,我对项目进行了重建,瞧!它对我有用。

回答by RaviK

Thanks for your help.

谢谢你的帮助。

I gave complete path of xCopy and it worked for me.

我给出了 xCopy 的完整路径,它对我有用。

%windir%\system32\xcopy

%windir%\system32\xCopy "$(ProjectDir)app\ExtjsWS\build\*.*" "$(publishUrl)\app\ExtjsWS\build" /y /i/e</PostBuildEvent>

回答by pduan

In my case: i fix it do this: Add value %SystemRoot%\system32 to Environmental variable's Path variable,and restart my computer,rebuild the solution,it goes fine.

在我的情况下:我修复它这样做:将值 %SystemRoot%\system32 添加到环境变量的 Path 变量,然后重新启动我的计算机,重建解决方案,一切顺利。