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
Next I ran a build, and here’s what came out:
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.
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.
3. Now paste the following into the script, just before the closing </Project> tag:
<PropertyGroup>
<WebBinariesLocation>$(BinariesRoot)\Mixed Platforms\Release\_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 Platforms\Release 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.









