We needed to build a Sharepoint WSP file in TFS as part of our continuous integration process. Already using WSPBuilder interactively we just needed to get it into the team build and copied to the staging location.
Brian Farnhill discusses the process of building a WSP in TFS by first including it in the project file (summary by Alex Degaston). This pointed me in the right direction, but I really just wanted to build the WSP in the team build after check-in.
We just copied the basics from Brian's post, and hoped it would work, and amazingly, we had a WSP file. Frustratingly, the WSPBuilder will happily create a WSP file even if it finds nothing to put in it.
After some experimenting on the command line, it turns out you need to specify both SolutionPath and BinPath to get WSPBuilder to build successfully, using the team build property OutDir worked for this. Including the feature.xml and workflow.xml as content in the root of the project ensures they're in the output folder.
The default name for the WSP is the folder name, so to override this, use WSPName.
The easiest way to get the files out was to override BeforeDropBuild and put them in the OutDir. I'm using xcopy for this as it's easier to test on the command line (also, using the copy task would require (I think) further nesting the copy operation because of the order of item expansion). They're then ready for the team build to perform the drop to the staging location.
All this boils down to this two liner added to the TFSBuild.proj:
<Target Name ="BeforeDropBuild" >
<Exec Command='"C:\Program Files\WSPTools\WSPBuilderExtensions\WSPBuilder"
<Exec Command='xcopy /E /Y /I