MSBUILD fails with “The process cannot access the file xxxxx because it is being used by another process.” when maxcpucount is greater than 1

那年仲夏 提交于 2019-12-07 03:09:36

问题


I'm trying to improve build times using CruiseControl.NET and MSBUILD, and one of the commandline switches, maxcpucount can be used to allow the build occur in parallel. Our solution has 60+ projects so any improvement would be helpful. However, whenever I up the maxcpucount above one, we have frequent build failures due to:

"The process cannot access the file xxxx because it is being used by another process. msbuild"

It appears that the additional parallel build threads/processes are locking each other.


回答1:


I think I found a solution. It appears that if I add the /nodeReuse:false switch I don't get the file locks. It seems like the nodeReuse functionality is keeping msbuild processes around and those are hanging on to file locks for subsequent builds.

http://msdn.microsoft.com/en-us/library/ms164311.aspx




回答2:


Are you building from a solution file? If so, make sure that you are using direct project-to-project references and not using the Solution's project-dependency feature. If you happen to be using a bit of both, there can be issues. See this article.

Better yet, if at all possible, ditch the solution file and create your own MSBuild file to drive your build.




回答3:


Your assembly is probably being used by another assembly thats being built. Make sure each assembly gets built before it's needed by other assemblies



来源:https://stackoverflow.com/questions/6838779/msbuild-fails-with-the-process-cannot-access-the-file-xxxxx-because-it-is-being

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!