Geeks With Blogs

News
(Amazon Affiliate Ads)

Mike Parks Code.Where(c => c.IsTechnicalDebt).Refactor();

We've recently implemented a new branching strategy for our Team Foundation Server's Source Control. It was a great idea that's working out well but it caused a few problems with our Continuous Integration builds.  The builds were failing with this error:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

It's a pretty common error and I'm sure most of you build engineers have seen this before. Keep in mind that this is not a TFS limitation, it is caused by a Windows limitation.  An easy way to fix this it to change the working directory of your Build Agent:

  1. In your Team Explorer 2008 window, right click on the Builds folder
  2. Click on Manage Build Agents
  3. Make sure your build agent is highlighted and click the Edit button
  4. Change the default working directory from $(Temp)\$(BuildDefinitionPath) to C:\b\$(BuildDefinitionId)


This will give you a lot of extra characters for your build server to work with.  The file path still needs to be under 260 characters though.  If you're wondering which C drive this references, it's the C drive on your build server. By changing this I've shortened the working directory path:

  • From: C:\Documents and Settings\tfsBuild\Local Settings\Temp\MikeTFS\Development - MikesProgram
  • To:      C:\b\1
You can delete everything out of the old working directory to free up some space on the build server if you're no longer using those builds.


So that should fix the issue. I did also want to give a little more information on working directories. Working directories are stored on your build server.  The working directory can be referenced by each build definition. Each time a new build is queued, a working directory folder will be created or modified under C:\b\$(BuildDefinitionID). Three sub folders are created inside this working folder (Binaries, BuildType, and Sources):

Binaries
folder: Contains the binary output from the build
BuildType
folder: Contains the build log and MSBuild files (TFSBuild.proj, TFSBuild.rsp, TFSBuild.tbrsp)
Sources folder: Contains the files downloaded to the build server mapped by the build definition you set up. See below.

For example, for the sources folder, TFS will perform a GET on the workspace you specify in the build definition and place all the files into $(SourceDir), which in our case would be C:\b\1\Sources. It uses these files to build your application on the build server. So it's important that each build definition is mapped out correct. You can also only map the workspace working folders that you need in order to speed up your build.




Hope this helps! Leave me some feedback if you get a chance.  Thanks everyone.

- Mike

 

Posted on Saturday, June 20, 2009 12:40 PM | Back to top


Comments on this post: Team Build 260 Character Path Limit Workaround

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
Hi Mike,

You're right, this is not an inherent limitation in TFS, any build system could have been affected by exceeding the max path length on windows.

Thanks for the tips!

Mr. Hericus
Left by Mr. Hericus on Jun 20, 2009 3:56 PM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
Unfortunately I have to disagree - it isn't a Windows limitation, it's a TFS limitation inherited from using the .NET Framework.

Why do I disagree although the linked MSDN article states exactly the same? Well, it depends on how you use the Windows API. You can pass standard filenames as the .NET Framework does in all operations which limits you to 260 characters. Or you can use the "\\?\" prefix practically everywhere and extend the limitation to 32,767 characters. Because the .NET Framework had to run on Win98 and WinME (which only support 260 chars) they chose to implement it that way. Now everybody using file operations on .NET is bound to those limits because there's no way to support 'long long filenames' in applications without using P/Invoke everywhere... :-(

What can TFS do about it? Nothing. At least not in their code base. But they could try to push the .NET BCL Team to support the full Windows limit when passing file names with the respective prefix.
Left by Ooh on Jun 29, 2009 12:14 PM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
Good description!
Left by Dan on Aug 11, 2009 12:02 PM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
When a limitation in the tool used to build software comes through in the software, this is a limitation in the software. The lesson is clear. Use a proper development language rather than a toy like .net.

For Microsoft development managers to to have foreseen the limitation is unforgivable.
Left by Richard on Feb 02, 2011 7:48 AM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
Very helpful! I just ran across this limit for the first time today with a crazy-long file name. Great workaround.
Left by Marcie on Mar 18, 2011 10:05 AM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
the workaround only saves you some letters. A question of time the next even longer path comes across.
i've also heard from our admin the database schema in tfs uses the same restriction.
So this will not change any time soon :/
Left by ossi on Mar 29, 2011 6:47 AM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
limitation of team building
Left by karthikeyan on Mar 19, 2012 3:06 AM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
On the subject of tips for shortening paths
1: If you project is e.g. called Company.Server.Web or similar it has the same path on disk. If often remove the project, shorten file on disk to e.g. Web and re-add project.

2: Search for the "FileListAbsolute.txt" in your project folders on your dev machine. This is generated on each compile. Good to quickly find the longest paths

Left by Jakob on Apr 01, 2012 7:42 PM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...
Thanks for the info. You could also try "Long Path Tool". It helped me with Error 1320 on Win 7. :)
Left by GarryBrown on Mar 06, 2013 3:54 AM

# re: Team Build 260 Character Path Limit Workaround
Requesting Gravatar...

Try Long Path Tool!

www.longpathtool.com
Left by Kermiy on Mar 27, 2013 1:37 PM

Your comment:
 (will show your gravatar)


Copyright © MikeParks | Powered by: GeeksWithBlogs.net