Thursday, 29 April 2010

Missing Reference name while building with Team Build

I recently spent quite a lot of time, uncovering this rather bizarre looking error in our Team Build. We start getting it when I moved one happy perfectly working build from a TSF 2008 build agent running to a new TFS 2010 Build agent. As soon as I ran the build on the new server, I start getting an error in one of the projects

Class1(14,27): error CS0234: The type or namespace name 'Class1' does not exist in the namespace 'namespace1' (are you missing an assembly reference?)

Tried the same build in the original Build agent and it did built without any problems. Ran the build again with diagnostics log. From the log files I spotted that where my project was getting compiled using Csc.exe , it didn’t include reference to a project. So, I checked again where the project being reference was getting built and yes it was. Also, it was built before the project what was referencing it. So on the face of it everything looked good. But it won’t still build!

Next thing was to try building the solution manually using MSBUILD. So wrote something like

Msbuild.exe mysolution.sln
It ran successfully without a hitch. Now, it was getting interesting. But hang on Team Build does use Multi-processor support while invoking msbuild. So, ran msbuild again with a /m switch

Msbuild.exe /m mysolution.sln


Here we go, I got exactly the same problem. So the build work fines when someone is compiling using one processor but not with multi-processor. So, what happened there?

With some support from Microsoft Visual Studio support team, found that it could be a problem that that path of the project file was too long. So looked back and yes it was. The path of the project that the other project was referencing was 262 characters. Reduced the path length by reconfiguring my build agent to build on a shorter named base directory and bang it worked correctly.

So, if you hit by this problem that a build doesn’t work when maxcpucount is greater than one, do check your path lengths.

No comments: