- First, create a Web Deployment Project for your Web Application Project. (If you have a Web Site Project, you will need to convert the Web Site Project to a Web Application Project before continuing.)
- Set the Output Folder to the destination UNC for the Debug and Release build types.
- Set any other WDP properties appropriate to your environment, such as Web.config file section replacement.
- Make sure your build server has VisualStudio and VS SP1 installed. If the server does not have the C:\Program Files\MSBuild\Microsoft\WebDeployment\ folder, you may need to install Web Deployment Projects as well.
- Create fixup.TeamWebDeployment.targets (see below) in C:\Program Files\MSBuild\. Normally, the Team Build drop location overrides the Output Folder, so this file adds a second compile task to put the web app where you wanted it to go in the first place.
- Add an import directive for $(MSBuildExtensionsPath)\fixup.TeamWebDeployment.targets.
- Create the team build, choosing your solution and build type, but you MUST choose Mixed Platforms as the Platform, or things will go very badly for you.
- Cross your fingers and run the build.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="AfterBuild" Condition="$(OutputPath) != $(WDTargetDir)">
<RemoveDir Condition="'$(DeleteAppDataFolder)' == 'true'" Directories="$(OutputPath)\App_Data"/>
Also, I have to ask any MS folks out there: Why C:\Program Files\MSBuild\ ? Why not C:\Program Files\Common Files\MSBuild\ or C:\Documents and Settings\<current/all user(s)>\Application Settings\Microsoft\MSBuild\ ? This adds yet another customizable location that needs to be backed up.
If you reference another project in the solution (or if there's any chance you will in the future), you'll need to also do the following.
Replace the <SourceWebPhysicalPath> line of the .wdproj file with:
Your path may vary, e.g. it may include a directory for Platform, so you may have to spend some time figuring out exactly how the path should look.
Once this change is made and checked in, both local and team builds work OK.