How to change the Working Directory of a Team Foundation Build agent

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.

image

Open the Manage Build Agents... dialog.

image

For the selected Team Project I have one Build Agent namely TFB01. Click Edit...

image

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\.

image

Next I changed the Working Directory for the TFB01 Build Agent as follows:

image

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 ...

Tags: , ,

Team System | Visual Studio

Comments

10/15/2008 6:01:15 PM #

Lambros Vasiliou

Hello,
The variable $(BuildDirectory) actually points to the working directory of the build agent. It is not treated as the environment variable. So in reality you are setting the working directory to the working directory plus something else. This can cause issues when creating new build definitions (TFS2008)

Lambros Vasiliou | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading