Here is a great resource on how to build team projects for SharePoint in TFS 2010 (also lists steps for TFS 2008).

http://msdn.microsoft.com/en-us/ff622991.aspx

Quick reference excerpt from the article below:

Steps TFS2010 TFS2008
1 Install Team Build software Same as TFS2010
2 Skip this step - TFS2010 already installs .NET Framework 4. Install .NET Framework 4.0 and update build path of TFS
3 Install Windows SDK to get GACUtil if you don’t already have one on the build system Same as TFS2010
4 Skip this step - TFS2010 already installs the DSL assembly. Install DSL Assembly Microsoft.VisualStudio.Modeling.Sdk.10.0.dll
5

Install the SharePoint assemblies:

  • Microsoft.SharePoint.dll
  • Microsoft.SharePoint.Security.dll
  • Microsoft.SharePoint.WorkflowActions.dll

If your project refers to other SharePoint assemblies, copy them to the build system too.

Same as TFS2010
6

Install the SharePoint tools targets and tasks

  • Microsoft.VisualStudio.SharePoint.targets.dll
  • Microsoft.VisualStudio.SharePoint.Tasks.dll
Same as TFS2010
7

Install the SharePoint tool assemblies:

  • Microsoft.VisualStudio.SharePoint.
    Designers.Models.dll
  • Microsoft.VisualStudio.SharePoint.
    Designers.Models.
    Features.dll
  • Microsoft.VisualStudio.SharePoint.
    Designers.Models.
    Packages.dll
  • Microsoft.VisualStudio.SharePoint.dll
Same as TFS2010
8

Build and package the SharePoint projects.

In TFS2010, this can be customized through the UI of the Build Definition. Under the Compilation category, in the MSBuildArguments field, add the following script:

/p:IsPackaging=True

For TFS2008, when you queue or start a build, you can add the script to activate the package task in the MSBuild command-line arguments text box:

/p:IsPackaging=True

If you want the package be created every time the build definition is used, add the script to the generated build file.