最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】xxx\Microsoft.Common.targets: error MSB3073: The command xxx exited with code 4

C# crifan 7113浏览 0评论

【问题】

在VS2010中编译一个C#项目,结果出错:

PostBuildEvent:
  XCOPY /D /Y /R "D:\tmp\xxx\InsertSkydriveFiles\bin\Debug\crifan.InsertSkydriveFiles.dll" "C:\Program Files (x86)\Windows Live\Writer\Plugins"
  D:\tmp\xxx\InsertSkydriveFiles\bin\Debug\crifan.InsertSkydriveFiles.dll
  Sharing violation
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3717,9): error MSB3073: The command "XCOPY /D /Y /R "D:\tmp\tmp_dev_root\wlw\InsertSkydriveFiles_v4.0_2012-04-02-office\InsertSkydriveFiles\bin\Debug\crifan.InsertSkydriveFiles.dll" "C:\Program Files (x86)\Windows Live\Writer\Plugins"" exited with code 4.

Build FAILED.

Time Elapsed 00:00:01.00
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

【解决过程】

1. 看到上面的错误提示中,有对应的PostBuildEvent和XCOPY,然后知道了是上述的XCOPY命令出错了。

2.网上从  MSB3073: exited with code 4 得知“MSB3073 is just a generic error that means an Exec task returned a non-zero error code. ”。且在这里 Xcopy,中找到exit code 的含义:

Exit code

Description

0

Files were copied without error.

1

No files were found to copy.

2

The user pressed CTRL+C to terminate xcopy.

4

Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.

5

Disk write error occurred.

对照解释来分析此处的错误原因:

(1)no enough memory or disk space:此处硬盘空间足够大,故不是此原因

(2) entered an invalid drive name:之前此命令可以正常执行的,所以也不是此原因。

(3)invalid syntax on command line:同上,故也不是此原因。

官方文档描述的原因,都不匹配。

3. 后来还是自己找到了原因:XCOPY所拷贝的目标文件“"C:\Program Files (x86)\Windows Live\Writer\Plugins”中的“crifan.InsertSkydriveFiles.dll”正在被使用,导致XCOPY无法覆盖式的将crifan.InsertSkydriveFiles.dll拷贝过去,才导致上述错误的。

而“crifan.InsertSkydriveFiles.dll”正在被使用,是因为其是WLW(Windows Live Writer)的一个插件,而当前打开了WLW,插件也被加载了,所以是“正在使用”,导致XCOPY无法将原先的crifan.InsertSkydriveFiles.dl拷贝到C:\Program Files (x86)\Windows Live\Writer\Plugins,无法将其覆盖。

【总结】

如果出现MSB3073类错误,那么说明是程序运行出错(返回值非0)。

具体的错误原因,需要根据当前程序以及返回值来确定。

就像此处的,当前运行程序是XCOPY,返回错误代码是4,对应的根本原因找到了是无法把源文件拷贝到目标文件夹去,因为目标文件夹下的同名源文件正在被使用,而导致XCOPY出错,返回值为4的。

转载请注明:在路上 » 【已解决】xxx\Microsoft.Common.targets: error MSB3073: The command xxx exited with code 4

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.152 seconds, using 22.19MB memory