No Free Time

Because my therapist says I need to let things out

Team Build 2008 and Visual Studio 2008 Web Deployment Projects

with 3 comments

I wrote a post earlier this year about how difficult it was to get VS 2005 Web Deployment Projects and Team Build 2005 to play nicely together. Well in the 2008 versions it looks like they put some effort into removing a lot of the friction, so I want to explain how it works now and shout out that it’s much, much better than it used to be.

For the purposes of this example I created a simple website project, a web deployment project, and a basic build definition. There is a lot of information about how to create a team build definition in TFS 2008 so I’ll just gloss over that. The important points here are: a) the inputs (a website and a web deployment project) and b) the outputs.

The Build

The sample solution

1. The sample solution

Creating a build definition

2. Creating a build definition

Select the solution to build

3. Select the solution to build

04

4. Select the platform and configuration (Mixed Platforms and Release)

05

5. Finish

06

6. Create a build agent and enter the drop/staging location for the build

Next I ran a build, and here’s what came out:

The result of the build

The result of the build

 

Notice that within the _PublishedWebsites folder are two folders: ‘Website’ and ‘Website_deploy’. In this example they are identical; if I had set up custom web config replacements then in the ‘Website_deploy’ folder would be a customised web.config file.

If I hadn’t created a web deployment project, the Team Build would still create the ‘Website’ folder and deploy a compiled website. This is important because I believe that didn’t happen with Team Build 2005, it just dumped the compiled assemblies into the Release folder. (Please correct me if I’m wrong).

Deploying where you want

The next thing you (probably) want is to have the deployable website copied from the timestamped drop location to a static location for an IIS website. Here’s how to modify your build script to do this:

1. In the solution explorer, right-click on the build definition and select View Configuration Folder.

Select View Configuration Folder to see where the script is stored in source control

Select View Configuration Folder to see where the script is stored in source control

2. The files will not be downloaded to your machine yet – highlight them, right-click and select Get Latest Version. Now double-click the TFSBuild.proj file to open the build script.

 

Open the build script file

Open the build script file

 

 

3. Now paste the following into the script, just before the closing </Project> tag:

   <PropertyGroup>

    <WebBinariesLocation>$(BinariesRoot)Mixed PlatformsRelease_PublishedWebSites</WebBinariesLocation>

  </PropertyGroup>

  <Target Name=AfterCompile>

    <Message Text=Copying from out $(WebBinariesLocation) to $(DropLocation)/>

    <RemoveDir Directories=$(DropLocation) Condition=Exists(‘$(DropLocation)’)/>

    <ItemGroup>

      <ProjectSourceFiles Include=$(WebBinariesLocation)***.*/>

    </ItemGroup>

    <Copy

        SourceFiles=@(ProjectSourceFiles)

        DestinationFiles=@(ProjectSourceFiles->’$(DropLocation)%(RecursiveDir)%(Filename)%(Extension)’)>

      <Output

          TaskParameter=CopiedFiles

          ItemName=SuccessfullyCopiedFiles/>

    </Copy>

  </Target>

What this will do is copy each of the deployment folders in the _PublishedWebsites folder directly into the drop location you specified in step 6 of creating the build definition (above). You don’t need to add anything specific to do with the project (other than the Mixed PlatformsRelease path, but this won’t change between build projects). If you set up deployment projects for staging and production you will end up with 3 deployed websites (development, staging and production). Nice!

Obviously for the build to include the script changes you just made you need to check the file back in to source control.

Hope this clears things up.

Written by tad

November 18th, 2008 at 11:28 pm

Posted in infrastructure

Tagged with , ,

3 Responses to 'Team Build 2008 and Visual Studio 2008 Web Deployment Projects'

Subscribe to comments with RSS or TrackBack to 'Team Build 2008 and Visual Studio 2008 Web Deployment Projects'.

  1. [...] Making Team Build and Web Deployment Projects play nice: Part 2 Filed under: .net, CI, tfs — Tags: .net, CI, tfs — andrewmyhre @ 10:02 pm NOTE: This post applies to TFS 2005 and WDP 2005 only. For TFS 2008 and WDP 2008 the below does not apply. It’s much, much easier to work with Web Deployment Projects in Team Build in 2008 – you can read about it in my updated post. [...]

  2. Great post..Keep them coming :) Thanks for sharing.

    ScriptoManiac

    5 Dec 09 at 10:25 pm

  3. I am using the same procedure as you described but i have to include deployment project as well else i miss a single assemble file (generated against for the web page code behind files ascx.vb/.cs, aspx.vb/.cs files)

    [Notice that within the _PublishedWebsites folder are two folders: ‘Website’ and ‘Website_deploy’. In this example they are identical; if I had set up custom web config replacements then in the ‘Website_deploy’ folder would be a customised web.config file.

    If I hadn’t created a web deployment project, the Team Build would still create the ‘Website’ folder and deploy a compiled website. ]

    The WebSite FOlder contains satellite assemblies like App_web_*****.dll. On the contrary, Website_Deploy Folder contains a single compiled Assembly like website.deploy.dll instead of the 20-30 satellite assemblies.

    If deployment project were not there in the solution file, only the Website folder is created inside _PublisheWebsites fodler. But what to do of satellite assemblies like app_web_dll? Each of these assemblies correspond to aspx.vb and ascx.vb files from the Asp.Net website.

    Kindly help.

    Thanks

    Awais

    18 Jun 10 at 10:48 am

Leave a Reply