Have you ever opened Team Explorer to kick off a build and watched in awe as the server stayed in the “Getting Sources” state for several minutes when the actual source code should only amount to a few kilobytes? If so, this blog’s for you!
The default for a new build created by the “New Build Type Wizard” from Team Explorer is to copy all of the source code for the entire Team Project into an intermediate directory before attempting to compile it. As seen in Figure 1, the default build copies everything outlined in red, even though you might only need the folder shown in blue.

Figure 1. Default versus necessary code copy.
One way to solve this is by segmenting the Team Project into smaller pieces, but sometimes this just does not make very much sense and can also be a maintenance nightmare. Instead, you can make a simple edit to the Build script to only copy the necessary files before trying to compile.
1. From Source Control Explorer check out and open the $/_TeamProject_/TeamBuildTypes/_BuildType_/TFSBuild.proj file, substituting the appropriate values for _TeamProject_ and _BuildType_.
2. At the very bottom of the file, paste the following XML between the closing ItemGroup tag and the closing Project tag.
<Target Name="CoreGet"
Condition=" '$(IsDesktopBuild)'!='true' "
DependsOnTargets="$(CoreGetDependsOn)" >
<!-- Get all the latest sources from the given workspace-->
<Get Condition=" '$(SkipGet)'!='true' "
Workspace="$(WorkspaceName)"
Recursive="$(RecursiveGet)"
Force="$(ForceGet)"
Version="$(VersionToGet)"
FileSpec="$/Cadabra/Infomentum/QdabraWebDavRootHandler/Properties" />
</Target>
3. Alter the value for the FileSpec attribute to match your project.
4. Save the file, check in, and initiate the build.
5. Compare build times to realize how much time you just saved.
Below are some links to the articles that helped me figure this out and a screenshot with a bigger view on the .proj file so you know exactly where to paste the code snippet.
· http://msdn2.microsoft.com/en-us/library/0k6kkbsd.aspx
· http://msdn2.microsoft.com/en-us/library/aa337598(VS.80).aspx
· http://blogs.msdn.com/nagarajp/archive/2005/10/21/483590.aspx

Figure 2. The final result of the Build edit.