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:
- In your Team Explorer 2008 window, right click on the Builds folder
- Click on Manage Build Agents
- Make sure your build agent is highlighted and click the Edit button
- 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