Build fail due to a project filepath of 195 char : "referenced project '..\x\x.csproj' does not exist."
I am trying to solve a weird issue with VS projects upgraded from VS 2008 to VS 2010. Some of them does not compile anymore (neither locally nor on the build server). I get the error "type or namespace name 'xxx' does not exist in the namespace 'xxxxx' (are you missing an assembly reference?)" and a warning (root cause of the error) : "The referenced project '..\x\x.csproj' does not exist.".
I found that this warning only occur when the filepath is 195 char long. Here is a zip file with a solution with reproduce the problem on my machine as well as on the build server and on colleagues' machines: http://valery.letroye.be/Uploads/TFS_Builds.zip
Unzip this pack on your C:\ or D:\. The resulting path should be like "C:\TFS_Builds\5\XXXX 1.1\Release 1.11\Sources\Release 1.11\Exception_Repository\"
I would really enjoy to hear someone telling me that it compiles fine on his machine, meaning that it's our working platform which is the root cause. Otherwise, if you experience the same issue, please help me to find the root cause ! Why 195 characters in lenght, not more not less (apparently) ? I am only aware of the "260 characters in length" limit of TFS.
Notice: using a longer or shorter path solve the issue. One project is a testing project. The "missing" reference is in this project. The tested project in this case was intended to be a windows service. Our local workstations are XP x86. The build machine is Server 2008 x64. I target .NET 3.5 (Targeting 4.0 solve the problem).
thx a lot in advance
PS.: I know that VS can't create projects in folders path longer that 248 characters and that the fully qualified file name must be less than 260. But everybody knew how to work around this limitation (creating everything in shorter path and moving the solutions into the target path later). How to check that this could be the issue here ??? The limitation used to be only for "creating" the path.
If you change any project filename or foldername (one letter less or more is enough), the problem is gone ?!?!
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)
A: The path of a referencing project’s directory.
B: The relative path to a referenced project from the current directory (= a referencing project’s directory).
If the sum total is one less or one greater than 259 it all works fine!
This issue occurs due to a bug in the Path.GetFullPath in .NET Framework library. This is a known issue in Visual Studio 2010. More information: http://support.microsoft.com/kb/2516078
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.
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by lucy-liuModerator Thursday, July 21, 2011 2:47 PM