Here's how to Team Build a Web Application Project

    General discussion

    1. 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.)
    2. Set the Output Folder to the destination UNC for the Debug and Release build types.
    3. Set any other WDP properties appropriate to your environment, such as Web.config file section replacement.
    4. 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.
    5. 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.
    6. Add an import directive for $(MSBuildExtensionsPath)\fixup.TeamWebDeployment.targets.
    7. 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.
    8. Cross your fingers and run the build.
    Code Snippet

    <Project DefaultTargets="Build" xmlns="">
        <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.

    Wednesday, May 16, 2007 5:06 PM

All replies

  • 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:
    Code Snippet

    <SourceWebPhysicalPath Condition="!Exists('..\..\Binaries\$(Configuration)\_PublishedWebsites\WebApp')">..\WebApp</SourceWebPhysicalPath>
    <SourceWebPhysicalPath Condition="Exists('..\..\Binaries\$(Configuration)\_PublishedWebsites\WebApp')">..\..\Binaries\$(Configuration)\_PublishedWebsites\WebApp</SourceWebPhysicalPath>

    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.

    Thursday, June 28, 2007 4:48 PM