How can I prevent a build from failing when trying to access a locally cached nuget package that is being lockedby another project in the same build?

StackOverflow https://stackoverflow.com/questions/23565315

We have CI set up on a solution within the company.

The build was taking roughly 13 minutes in total, which seemed a bit a too long. After some digging around, I found out that the we were not passing the /maxcpucount switch to the msbuild command, and so each project was being built in sequence as opposed to parallel. Adding this switch dropped our build time down to 3 minutes.

However, we started seeing builds intermittently failing with the message that a cached nuget package was already being used by another process. The project that would fail to build, and the locked nuget package would change every time.

This turned out to be because we were building multiple projects within the same solution at the same time, and we could get the circumstance whereby two projects building in parallel tried to access the same locally cached nuget package at the same time.

We surely can't be the only people with this problem, as it seems like it would be quite common. Does anyone have experience with this problem? Are we doing something wrong? How can we prevent these builds from failing?

有帮助吗?

解决方案

So I finally figured what was causing this, although I can't figure out why.

In our Teamcity MSBuild step, we had our Working Directory set to %build.root%. Removing this value, so that the default of the checking directory was used, appears to have stopped that error from occurring.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top