I’m currently working on creating an automated build procedure using TFS. For the most part it is pretty great. One thing that is really cool is the ability to instrument each step, or even parts of a step. For example, if you’re doing something post compilation (like running a database script) you can add steps in the build script so that “building database” shows up as a step in the progress log and will either get a green check, or a red cross after it is done.
My Issue: 260 character limit
I adding another solution to be built and ran into an error when the source was compiled. The build log was very clear:
”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.”
This is a Windows issue, and there isn’t a way to get around it. So, I needed to understand how this happens and what the options are.
When TFS runs the command to get the source code, it gets the source to a specific folder called $(SourceDir).
It was not so clear how the $(SourceDir) was constructed, nor where I could change things so that the path wasn’t as long. Bing led me to articles that gave me this understanding:
- $(SourceDir) = $(BuildDir)\Sources
You can set the “sources” part in the config file of the TFS engine on the build machine. So, for example, you can have $(SourceDir) = $(BuildDir)\S
- $(BuildDir) = C:\Build\$(BuildDefinitionPath)
This is set in the build agent
- $(BuildDefinitionPath) = <team project name>\<definition name>
<team project name> is quite a big deal, and you can’t change that easily.
<definition name> is the name of the build you are executing, and this can be changed with much less impact. Keep in mind that you will need to have rights on TFS to administer builds if you want to rename and/or add a build definition
= C:\Build\My Project\My awesome build\Sources
- Change the name of the project that caused the issue
I could not change the names of the projects that resulted in creating the long path
- Trim the $(SourceDir) of a couple of characters.
- Change the name of the team project in TFS
Not so cool since all the workspaces are tied to this and people are used to the name
- Change the “Sources” part in the config file
Not ideal since this will affect all the builds from other teams as well.
- Change the name of the Build Definition
Much less isolated change
I solved my problem by changing the build definition name. I only needed to trim one character, but the name changed from “On Demand QA Deployment” to “QADeploy”.
- TFS Top Tips #16 – Limit what you Build – Martin Woodward
- Aaron Hallberg : Team Build and 260+ Character Paths