File Path of greater than 260 characters with TFS Automated builds

Working with TFS automated builds for BizTalk I have started to run into the TFS / MSBuild file path length restrictions (no, I don’t understand in modern operating system why the build process has a file path limit) and have tried several ways to reduce the path length, with varying degrees of success, this week I discovered one way to help reduce the path length without compromising the TFS Automated build process and I would like to share it with you.

Example of the default location for the source on a build server, I have highlighted one of the longer examples:


In the TFS build Agent there is a variable that controls the start of the source location on the build server, it is called Working Directory


The default value for this is:


In the build server I have this is:


The last part of this is the source tree path and the name of the build, which are typically much longer than this example.

To reduce this I found that we can change $(BuildDefinitionPath) to $(BuildDefinitionId)


This changes the starting path to:


This is reduce the path by 13 characters, but if your source tree path and build definition name are a typical size this may reduce the path by almost 100 characters, without compromising any part of the build process.

The previous list of files now looks like this:


I hope this tip helps solve your automated build path lengths issues.

Comments are closed.