VS2010 deployments using TFS2010 Build Server
My TFS2010 Build Server Config
- Windows Server 2008R2 x64
- Installed Application Server role, including .NET 3.5.1 and .NET 4
- Installed TFS2010 Controller service and 1 Build Agent Service
- Configured TFS Controller service to run under custom domain account, no special privileges assigned in advance ([domain]\TFSBuildSVC)
- Installed VisualStudio 2010 Ultimate (with C#, Web Developer and SharePoint tools)
- Put Oracle.DataAccess.dll (2.112.1.0) into GAC to support oracle connections (used in our web projects)
- Installed SharePoint 2010 resources for building SharePoint 2010 projects in TFS2010 (http://msdn.microsoft.com/en-us/library/ff622991.aspx). I used the powershell script provided by microsoft to copy over/setup the TFS server (http://blogs.msdn.com/b/vssharepointtoolsblog/archive/2010/04/14/building-visual-studio-sharepoint-projects-using-team-foundation-build.aspx)
- Installed ASP.NET MVC 3 RTM
Enable web.config Transforms for TFS 2010 Builds
Found this solution on Kevin Daly's Blog. Unfortunately it involves editing the project/solution files to make it work.
- Make a master list of build targets for the projects in your solution. Assuming all build targets will be used in at least one web.config transform, you'll need to keep track of them for use later in the TFS build definition.
- In your TFS build definition, go to the Process section and add the build configurations from step 1 to the "Items to build->Configurations to Build" section. Be sure to define the configurations exactly as you have then in your solution.
- In the solution explorer, unload the project you want to add the transform to, then right click the project name and edit the project file. Add the following XML chunk just before the last </Project> tag:<Target Name="AfterBuild" Condition="$(IsAutoBuild)=='True'">
<ItemGroup>
<DeleteAfterBuild Include="$(WebProjectOutputDir)\Web.*.config" />
</ItemGroup>
<TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\Web.config"/>
<Delete Files="@(DeleteAfterBuild)" />
</Target> - Edit the TFS build definition again. In the "process" section, go to "Advanced->MSBuild Arguments" and add the following parameter/p:IsAutoBuild="True"
That should do the trick. Run the build and if it succeeds, open the drop folder and browse into the "_PublishedWebsites" folder. Find your project and check the web.config to confirm it produced the right results.
Create Web Deploy Package with TFS
To create a Web Deploy package for your project in the drop folder, you need to throw a few more MSBuild parameters into the TFS build definition.
These switches just create the package on the filesystem. Also, your project "Package/Publish Web" settings should be configured in VS2010 (usually the defaults are fine).
Build Server Errors
- ... The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.This error means that the build box is missing some files required to perform the project MSBuild. In this case, I was trying to perform a web.config xml transform for a VisualStudio 2010 web application project. I was able to fix the issue by installing VS2010 on the build box. I'm guessing its a safe bet to install your typical workstation development tools on the build box to make sure that all your build requirements are met.
Resources
- Web deployment switches for TFS2010 builds:
http://weblogs.asp.net/jdanforth/archive/2010/04/24/package-and-publish-web-sites-with-tfs-2010-build-server.aspx - How to build SharePoint Projects with TFS Team Build
- TFS Web Deployment Packages (and other info about continuous integration)
- More TFS2010 MSBuild deployment switches: Team Build + Web Deployment + web Deploy + VS2010 = Goodness