xxx\Microsoft.Common.targets: error MSB3073: The command xxx exited with code 4

http://www.crifan.com/microsoft_common_targets_error_msb3073_command_exited_with_code_4/

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

?
1
2
3
4
5
6
7
8
9
10
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的。

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值