Modifying the default Team Build
One annoying thing about Team Builds created through the Team Build wizard is that they pull down all the source code in the entire Team Project by default. This is almost never what I want. But it's easy enough to fix.
First, check out the TFSBuild.proj and WorkspaceMapping.xml files from the TeamBuildTypes folder in source control.
Remember, the build user is just a user, exactly like you. And it has workspace mappings, just like you do. But in this case the workspace mapping is too broad. It's at the root of the Team Project. Let's fix that by editing WorkspaceMapping.xml. Change it from this..
<Mappings>
<InternalMapping ServerItem="$/TeamProject1" LocalItem="C:\does-not-matter"
Type="Map" />
</Mappings>
To this..
<Mappings>
<InternalMapping ServerItem="$/TeamProject1/DemoBuildWebApp"
LocalItem="C:\does-not-matter"
Type="Map" />
</Mappings>
All we're doing is adding the Solution folder to the Team Project path. This is the key fix-- until we do this, the build user will get latest on the entire source tree. That's no good.
Two additional notes about the build user workspace mapping file:
- If you do have a legitimate need to pull down a giant source tree, you can make it a little less painful by cloaking (aka hiding) some of the subfolders here.
- The path specified here is truly irrelevant. I changed it to C:\does-not-matter to make a point. The local path is always the server build folder, so whatever you put here is completely ignored.
Next, we need to update our compilation path to reflect the fact that it's no longer in a subfolder. Edit TFSBuild.proj and modify this section from..
<SolutionToBuild Include="$(SolutionRoot)\DemoBuildWebApp\DemoBuildWebApp.sln" />
To this..
<SolutionToBuild Include="$(SolutionRoot)\DemoBuildWebApp.sln" />
Now check in the changes, re-build, and you'll see in the build report and the build folder that only the specific source in the solution subfolder was retrieved. Big improvement!