For TFS 2008 Team Build, how to change where $Temp points to


We have recently built a new TFS 2008 Team Build server. I don't want users putting their builds in the default temp directory that is pointed to by $Temp for the Build Agent, but I also don't want to force developers to change the path to somewhere else – this runs the risk of developers either (a) not bothering, or (b) making paths that are not consistent with other teams.

So I would like to keep the $Temp there (which is the default for when creating a Build Agent), but change the location where that points to. How do I do that?

Best Solution

The $Temp value is the value of the Temp environment variable for the user that the build agent process is running as. You could change the temp location for the build user - however that might not be what you want as that is a setting you will have to do to the build users environment, not just localized to the build agent process.

Personally, I set my build agent working directories to something like d:\bw\$(BuildDefinitionId) where d is a fairly fast secondary drive - however c:\bw would do just as well. This means that the builds are conducted in a place with a short path so you are less likely to run into the annoying 260 character path limit imposed by .NET's IO classes.

Presumeably, creating build agent's isn't something that your developers are doing but more of an administrative task - however if you really wanted to make sure it was done how you wanted you could provision the build agent using the TFS Build API from an internal ASP.NET page or a little application. That would give you the control you need to limit where the build working directory is set.

If you want API code for creating a build agent then let me know in the comments and I will edit my answer.

Related Question