Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 927
JNappi Avatar asked Jul 27 '11 02:07

JNappi


2 Answers

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

like image 76
JNappi Avatar answered Nov 04 '22 18:11

JNappi


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.

like image 30
Brian Kretzler Avatar answered Nov 04 '22 18:11

Brian Kretzler