by Gabriel Lozano-Moran
14. January 2008 15:22
The CI build for one of our projects failed today giving the following 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.
By default the Working Directory of the Build Agents is set to $(Temp)\$(BuildDefinitionPath) which translates to %USERPROFILE%\Local Settings\Temp\<Team Project name>\<Build Definition Name>\.
Assuming that the TFB services are running under the TFSBUILD Service Account and the name of your Team Project is NHibernate and the Build Definition Name is NHibernate.Core.CI than you get the following paths which are already almost 100 characters out of the 260 limit:
- C:\Documents and Settings\TFSBUILD\Local Settings\Temp\NHibernate\NHibernate.Core.CI\Sources\
- C:\Documents and Settings\TFSBUILD\Local Settings\Temp\NHibernate\NHibernate.Core.CI\Binaries\
- C:\Documents and Settings\TFSBUILD\Local Settings\Temp\NHibernate\NHibernate.Core.CI\TestResults\
So how do we change the Working Directory to for example D:\Builds\<Team Project Name>\<Build Definition Name>? (With thanks to Swaha Miller, one of the developers on Team Build and the developer of the Team Foundation Build notification tool)
Start Visual Studio and you have to set the focus to a Team Project in the Team Explorer window, you need to do this in order to activate the Manage Build Agents... menu in the Build menu.
Open the Manage Build Agents... dialog.
For the selected Team Project I have one Build Agent namely TFB01. Click Edit...
Here you see that the default Working Directory is set to $(Temp)\$(BuildDefinitionPath). I want to replace $(Temp) with D:\Builds\ but instead of hard setting it I created a new Environment Variable on the TFB01 machine named BuildDirectory pointing to D:\Builds\.
Next I changed the Working Directory for the TFB01 Build Agent as follows:
Note however that the Working Directory can still be quite long but there are several more options namely replacing the $(BuildDefinitionPath) variable with $(BuildDefinitionID) and so on ...