微软建站TeamBuild-BuildInParallel因违反MSB3021文件权限而失败 [英] MSBuild & TeamBuild - BuildInParallel failing because of MSB3021 file permission violation

查看:157
本文介绍了微软建站TeamBuild-BuildInParallel因违反MSB3021文件权限而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护着相当大的软件,包括大约350个csharp项目.我们的调试时间大约是17分钟.

I maintain the build of a fairly large piece of software, consisting of roughly 350 csharp projects. Our build time for a debug built clocks in at about 17 minutes.

我一直在寻找改善构建时间的方法,并且BuildInParallel属性确实很吸引人.特别是由于我们有一个四核服务器来进行构建,因此它确实应该能够利用计算能力.

I have been looking at ways to improve build time, and the BuildInParallel property did look intriguing. Especially since we have a quad-core server doing our builds, it should really be able to take advantage of the computing power.

但是a ...在设置了属性,修改了构建代理的配置文件并重新启动之后,第一次运行确实看起来很有希望,比平时快得多,直到失败为止.

But alas... After setting the property, modifying the config file for the build agent and restarting it, the first run really did look promising, way faster than normal, right up until the point where it failed.

查看构建日志后,当试图将标记为CopyLocal = true的引用复制到输出目录时,构建似乎失败. 如果C#项目A和C#项目B是并行构建的,并且两者都引用相同的第三方dll,并尝试同时复制它,则第二个尝试复制文件的过程将遇到文件访问冲突-该文件正在被另一个进程使用.

After looking at the build logs, it looks like the build fails when it attempts to copy references marked as CopyLocal=true to the ouput dir. If C# project A and C# project B are built in parallel, and the both reference the same third-party dll, and tries to copy it at the same time, the second process to attempt to copy the file will get a file access violation - the file is being used by another process.

任何人都经历过这种情况,并且能够在Team Build上进行多过程构建吗?

Anyone experienced this, and been able to get multi-proc builds working on Team Build?

这是失败的原因之一,很难弄清同时正在构建哪个其他项目.

Here's one of the failures, kind of hard to figure out which other project was being built at the same time.

我删除了所有不相关的内容:

I have removed all the non-relevant stuff:

54>文件中的目标"_CopyFilesMarkedCopyLocal" "c:\ WINDOWS \ Microsoft.NET \ Framework \ v3.5 \ Microsoft.Common.targets" 来自项目 "d:\ temp \ PCM \ 1.3-Maint_CI \ Sources \ Modules \ Core \ Test \ UnitTest \ TestDIPS.Core.Data.Server.NUnit \ TestDIPS.Core.Data.Server.NUnit.csproj": 54>任务复制" 将文件从".......... \ Bin \ 3rdParty \ Oracle \ Oracle.DataAccess.dll"复制到 "d:\ temp \ PCM \ 1.3-Maint_CI \ Binaries \ Debug \ Oracle.DataAccess.dll". 命令: 复制/y".......... \ Bin \ 3rdParty \ Oracle \ Oracle.DataAccess.dll" "d:\ temp \ PCM \ 1.3-Maint_CI \ Binaries \ Debug \ Oracle.DataAccess.dll" 54> c:\ WINDOWS \ Microsoft.NET \ Framework \ v3.5 \ Microsoft.Common.targets(2703,9): 错误MSB3021:无法复制文件 "........ \ Bin \ 3rdParty \ Oracle \ Oracle.DataAccess.dll" "d:\ temp \ PCM \ 1.3-Maint_CI \ Binaries \ Debug \ Oracle.DataAccess.dll".这 进程无法访问文件 'd:\ temp \ PCM \ 1.3-Maint_CI \ Binaries \ Debug \ Oracle.DataAccess.dll' 因为它正在被另一个进程使用. 完成执行任务复制"-失败. 54>在项目中完成构建目标"_CopyFilesMarkedCopyLocal" "TestDIPS.Core.Data.Server.NUnit.csproj"-失败.

54>Target "_CopyFilesMarkedCopyLocal" in file "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets" from project "d:\temp\PCM\1.3-Maint_CI\Sources\Modules\Core\Test\UnitTest\TestDIPS.Core.Data.Server.NUnit\TestDIPS.Core.Data.Server.NUnit.csproj": 54>Task "Copy" Copying file from "..........\Bin\3rdParty\Oracle\Oracle.DataAccess.dll" to "d:\temp\PCM\1.3-Maint_CI\Binaries\Debug\Oracle.DataAccess.dll". Command: copy /y "..........\Bin\3rdParty\Oracle\Oracle.DataAccess.dll" "d:\temp\PCM\1.3-Maint_CI\Binaries\Debug\Oracle.DataAccess.dll" 54>c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(2703,9): error MSB3021: Unable to copy file "..........\Bin\3rdParty\Oracle\Oracle.DataAccess.dll" to "d:\temp\PCM\1.3-Maint_CI\Binaries\Debug\Oracle.DataAccess.dll". The process cannot access the file 'd:\temp\PCM\1.3-Maint_CI\Binaries\Debug\Oracle.DataAccess.dll' because it is being used by another process. Done executing task "Copy" -- FAILED. 54>Done building target "_CopyFilesMarkedCopyLocal" in project "TestDIPS.Core.Data.Server.NUnit.csproj" -- FAILED.

推荐答案

MSBuild附带的默认目标是针对CopyLocal行为而设计的-这是VS所依赖的.当您输出到单个输出目录时,CopyLocal会出现问题.

The default targets that ship with MSBuild are designed for CopyLocal behavior - which is what VS relies on. CopyLocal is problematic when you're outputting to a single output directory.

要真正真正地并行构建,您需要在Microsoft.*.Common.*.targets文件中禁用一些特定于CopyLocal的行为.过去,我曾与MSBuild团队的一些人进行过交谈,这是一件特别艰巨的事情.即使您消除了某些CopyLocal行为,VS测试访问器在并行构建时也表现不佳.

To be able to truly build in parallel, you'll need to disable several CopyLocal specific behaviors in the Microsoft.*.Common.*.targets files. I've spoken with some folks in the MSBuild team in the past, and this is a particularly hairy thing to do. Even if you do blank-out some of the CopyLocal behavior, the VS test accessors don't behave well with build in parallel.

一些可以开始的事情:

  1. 通过将private设置为true禁用对引用的CopyLocal行为.
  2. 在构建依赖项目时禁用CopyToOutputPath文件的CopyLocal.

这篇关于微软建站TeamBuild-BuildInParallel因违反MSB3021文件权限而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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