构建时以代码4退出命令副本-Visual Studio重新启动解决了该问题 [英] Command copy exited with code 4 when building - Visual Studio restart solves it

查看:87
本文介绍了构建时以代码4退出命令副本-Visual Studio重新启动解决了该问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每隔一段时间,当我在这里构建我的解决方案(其中包含7个项目)时,在Visual Studio 2010 Premium ed中会出现可怕的命令副本退出并出现代码4"错误.

Every now and then when I build my solution here (with 7 projects in it) I get the dreaded 'Command copy exited with code 4' error, in Visual Studio 2010 Premium ed.

这是因为无法进行构建后事件.

This is because of the post-build event not being able to go through.

这是暂时解决问题的方法

Here's what solves the problem, temporarily

  • 有时候:重新启动Visual Studio,然后我就可以构建解决方案了
  • 有时:重新启动Visual Studio和我选择的文件管理器(Q-Dir 4.37)都可以解决.

这是构建后事件的样子:

Here's what the post-build event looks like:

xcopy "$(SolutionDir)Solution Items\References\*.dll" "$(TargetDir)" /Y

当您获得代码为[插入值]错误而退出的命令副本时,通常是由于以下原因:

When you get the command copy exited with code [insert value] error, it's normally because of the following:

  • 读取/写入权限
  • 缺少文件
  • 错误的目录

但是-很明显,有时在我构建解决方案时,没有问题.

However - obviously at times when I build the solution, there's no problem.

仅供参考,两周前,我卸载了ReSharper 5.1.1,自那时以来,Visual Studio一直给我一些错误(其中包括无法调试的错误).我重新安装了Visual Studio,自那时以来,它的工作情况更好,但仍然遇到此问题.可能与ReSharper中的某些东西有关吗?

FYI, I uninstalled ReSharper 5.1.1 two weeks ago and Visual Studio's been giving me some errors since then (among them not being able to debug). I re-installed Visual Studio and it's working better since then, but still get this problem. Could it have to do with some ReSharper stuff being somewhere?

您是否遇到过相同的问题并已解决?或者您对此有任何解决方案?

Have you had the same problem and solved it? Or do you have any possible solution to it?

推荐答案

我总是发现这是文件锁定问题.代码4是无法访问文件.我发现的一种局部解决方案是对xcopy使用/C选项(在发生错误时会继续).并不是真正的解决方案,但大多数情况下,它阻止了我的构建失败.

I've invariably found this to be a file locking issue. Code 4 is Cannot Access File. One partial solution I found is to use the /C option for xcopy (which continues on error). Not really a solution but mostly it has stopped my builds from failing.

另一种仅适用于32位的解决方案是使用 unlocker 工具来释放Windows句柄复制之前的文件上.

Another solution which only works on 32 bit is to use the unlocker tool to release the windows handles on the file before the copy.

我刚刚意识到它也可以在64位下工作.

I've just realised that it works under 64 bits too.

这篇关于构建时以代码4退出命令副本-Visual Studio重新启动解决了该问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆