What was the issue?
The issue was simple, she was not able to compile the application.
The issue was special in many ways because, all of us (i.e. her team members) were able to compile the project just fine. Even the continuous integration service - Jenkins (formally Hudson), was able to compile the application. We were not able to compile the application only on her machine. The build failed with the error
The project "AB.dosomeprojects.Services.FillImporter.Service.csproj" referred the project "abcdefgh.dosomeprojects.Common.csproj" which was in the path "..\..\..\abcdefgh.dosomeprojects\abcdefgh.dosomeprojects.Common". The path was relative to the Service project directory.
The directory structure was correct, Common project was correctly reffered from the Service project, but still we were not able to build the app on her machine.
Initially, we thought that there must me some local changes on her machine because of which, she was not able to run the build on her machine. Build was not passing neither with Visual Studio 2010 nor with MSBuild and that too only on her machine.
We looked for any local changes on her machine, but unfortunately her machine was clean. There were no local changes. We were simply clueless! Why does the project build fine on other developers machine while it does not build on her machine?
After some intense Googling, we found an interesting hidden treasure shipped silently by Microsoft Visual Studio 2010. I call such issues as hidden treasure because, I can hardly believe my ears when I hear/read about such an issue.
I am sure it will come as an surprise to you as well. The issue is:
The Real Problem:
Visual Studio 2010 fails to build the project when the following conditions are met:
- Solution with multiple projects exists, where there exists dependency relationships among them
- The sum of the following two path length is exactly added up to 259 characters (= MAX_PATH – 1)
- The path of a referencing project’s directory.
- The relative path to a referenced project from the current directory (= a referencing project’s directory).
Condition 1: We have solution with multiple projects where there exists dependency relationships among them
Yes, we do have the solution with multiple projects in it and one project depends on the other. In our case the AB.dosomeprojects.Services.FillImporter.Service.csproj depends on the abcdefgh.dosomeprojects.Common.csproj project. Hence, condition 1 is met.
Condition 2: The sum of the following two path length is exactly added up to 259 characters (= MAX_PATH – 1)
This one is tricky. Which path sum are we talking about?
Condition 2.1: The path of a referencing project’s directory.
The path of the referencing project's directory, in our case the path of the AB.dosomeprojects.Services.FillImporter.Service.csproj on the file system, which was, "E:\projects\ABC\SVN\dosomeprojectsweb\trunk\AB.dosomeprojects.Services\AB.dosomeprojects.Services.FillImporter\AB.dosomeprojects.Services.FillImporter.Service" has total length of 158 chars.
Condition 2.2: The relative path to a referenced project from the current directory (= a referencing project’s directory).
The relative path of the referenced project from the current directory, in our case its the relative path of abcdefgh.dosomeprojects.Common.csproj, which is, "..\..\..\abcdefgh.dosomeprojects\abcdefgh.dosomeprojects.Common\abcdefgh.dosomeprojects.Common.csproj" has total length of 101 chars.
The sum total of these two path lengths: 158 + 101 = 259!
Wow! condition 2 is also met.
As I said, we have uncovered an hidden treasure of Visual Studio 2010. Its unable to build the project when the path length of referencing project + path length of relative path to a referenced project = 259!
If the sum total is one less or one greater than 259 it all works fine! On other developers machine the total path length was less than or greater than 259 but was never equal to 259 and because of this reason we were all able to build the project but she was not able to build the project on her machine! Weird isn't?
This issue occurs due to a bug in the Path.GetFullPath in .NET Framework library. This is a known issue in Visual Studio 2010.
The Fix:
The workaround is pretty straight forward, rename one of the folders a bit longer or a bit shorter and make sure that, the sum of the two path length is NOT equal to 259 chars.
For more information on the issue visit the offical Microsoft Knowledge base article here http://support.microsoft.com/kb/2516078
Now you know, we are having so much fun with .Net (sarcasm intended)!