In a previous post, I provided a walkthrough for automating builds for VSEWSS 1.3 projects. The script I used was based on the SharePoint Guidance Drop 11, and after using it, I felt it could be simplified. I’m a proponent of implementing the “simplest possible thing that will work,” and the following build script contains the minimal functionality needed to automate the building and packaging of your SharePoint solutions.
<?xmlversion="1.0"encoding="utf-8"?><Projectxmlns="http://schemas.microsoft.com/developer/msbuild/2003"ToolsVersion="3.5"><ImportProject="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets"/><ProjectExtensions><ProjectFileVersion>2</ProjectFileVersion></ProjectExtensions><PropertyGroup><RunTest>false</RunTest><RunCodeAnalysis>Never</RunCodeAnalysis><SkipWorkItemCreation>true</SkipWorkItemCreation></PropertyGroup><PropertyGroup><ContosoSolutionDir>c:\NightlyBuild\main\</ContosoSolutionDir><ContosoSolutionName>Contoso.sln</ContosoSolutionName><ContosoWSPName>Contoso.Deployment.wsp</ContosoWSPName><ContosoDeploymentProjDir>c:\NightlyBuild\main\Contoso.Deployment\</ContosoDeploymentProjDir><IDEPath>C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\</IDEPath></PropertyGroup><ItemGroup><SolutionToBuildInclude="$(BuildProjectFolderPath)/../../main/Contoso.sln"></SolutionToBuild></ItemGroup><ItemGroup><ConfigurationToBuildInclude="Debug|Any CPU"><FlavorToBuild>Debug</FlavorToBuild><PlatformToBuild>Any CPU</PlatformToBuild></ConfigurationToBuild></ItemGroup><TargetName="AfterCompile"><!-- The extensions modify files in the pkg directory, so those files cannot read only--><BuildStepTeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"Message="Making the pkg directory editable."><OutputTaskParameter="Id"PropertyName="StepId"/></BuildStep><ExecCommand="attrib -R "$(ContosoDeploymentProjDir)pkg\*.*" /S /D"/><BuildStepTeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"Id="$(StepId)"Status="Succeeded"/><!-- Build using /package switch --><BuildStepTeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"Message="Packaging wsp."><OutputTaskParameter="Id"PropertyName="StepId"/></BuildStep><ExecCommand=""$(IDEPath)devenv" "$(ContosoSolutionDir)$(ContosoSolutionName)" /Deploy debug /Package"/><BuildStepTeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"Id="$(StepId)"Status="Succeeded"/><!-- Copy package to drop folder --><BuildStepTeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"Message="Copying wsp to drop folder."><OutputTaskParameter="Id"PropertyName="StepId"/></BuildStep><CopySourceFiles="$(ContosoDeploymentProjDir)bin\debug\$(ContosoWSPName)"DestinationFolder="$(DropLocation)\$(BuildNumber)"/><CopySourceFiles="$(ContosoDeploymentProjDir)bin\debug\setup.bat"DestinationFolder="$(DropLocation)\$(BuildNumber)"/><BuildStepTeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"Id="$(StepId)"Status="Succeeded"/></Target></Project>