CI 环境中的 MSBuild "Unable to copy file"

标签 msbuild hudson

我使用 Hudson 作为持续集成服务器。这些工作最终启动了 MSBuild。每个人都偶尔会遇到我的构建因 MSBuild 中的非代码编译错误而失败的情况:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(2703,9): error MSB3021: Unable to copy file "..\Lib\Microsoft\Microsoft.Practices.Unity.Configuration.dll" to "bin\Debug\Microsoft.Practices.Unity.Configuration.dll". Access to the path 'bin\Debug\Microsoft.Practices.Unity.Configuration.dll' is denied.

当我检查“bin\Debug\Microsoft.Practices.Unity.Configuration.dll”时,我发现它是一个 0 字节文件。

我不知道为什么这个文件有问题。有什么想法吗?

最佳答案

MS Build Copy 任务具有未记录的功能,至少 Google 保持沉默。 如果设置系统范围环境变量 MSBUILDALWAYSRETRY=1 即使在复制操作期间出现“拒绝访问”异常,此任务也会重试复制文件

输出示例

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (3513): Got System.UnauthorizedAccessException: Access to the path 'C:\Builds\8\28\Binaries\Release\fr\System.Spatial.resources.dll' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at Microsoft.Build.Tasks.Copy.CopyFileWithLogging(FileState sourceFileState, FileState destinationFileState)
   at Microsoft.Build.Tasks.Copy.DoCopyWithRetries(FileState sourceFileState, FileState destinationFileState, CopyFileWithState copyFile) copying C:\Builds\8\28\Sources\Main\Solutions\packages\System.Spatial.5.2.0\lib
et40\fr\System.Spatial.resources.dll to C:\Builds\8\28\Binaries\Release\fr\System.Spatial.resources.dll and HR is -2147024891
 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (3513): Retrying on ERROR_ACCESS_DENIED because MSBUILDALWAYSRETRY = 1
 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (3513): Could not copy "C:\Builds\8\28\Sources\Main\Solutions\packages\System.Spatial.5.2.0\lib
et40\fr\System.Spatial.resources.dll" to "C:\Builds\8\28\Binaries\Release\fr\System.Spatial.resources.dll". Beginning retry 1 in 1000ms. Access to the path 'C:\Builds\8\28\Binaries\Release\fr\System.Spatial.resources.dll' is denied.

关于CI 环境中的 MSBuild "Unable to copy file",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1133446/

相关文章:

c# - visual studio 中的条件引用 - 如何定义自定义变量

delphi - 如何让 MSBuild 完成相当于 dcc32 -b 的 Delphi 项目的完整构建?

msbuild - 如何使用Msbuild将程序集安装到GAC?

linux - hudson : Scheduling a build without a tag and generate a report

msbuild - YUI 压缩器和 TFS 构建

c# - 解决方案不在 Visual Studio 中运行/构建/重建

Jenkins 插件 : create a new job programmatically

continuous-integration - 在 Jenkins 中归档工件

python - 如何让 Jenkins 运行一个执行构建的python脚本?

svn - 配置 Jenkins 以使用 SVN 分支