TFS2010: Configure IIS from Team Build with a Custom Team Build Workflow Activity


I find that a lot of the applications I write use IIS in some way.  Silverlight, ASP.NET, WCF Services – these all usually need an IIS web application in order to run.  Since I’m a unit testing / test-driven development kind of a guy and a everything-should-be-repeatable kind of a guy and an if-it-doesn’t-run-from-an-automated-build-then-it-isn’t-real kind of a guy, this means that I’m going to need to deploy my application (Silverlight, WCF, ASP.NET, etc) in to IIS and then make sure that the security settings are all wired up properly. 

In TFS2008 and TFS2005, I’d do this using the Tigris MSBuild Community Tasks and the AfterCompile target in the Team Build script.  I could still do this in TFS2010’s Team Build implementation but TFS2010’s been re-written to use Windows Workflow (see screenshot below) and I wanted to do this without having to “shell out” to MSBuild. 


What does this mean?  This means that I needed to write a custom Build Workflow Activity and then create a build that would use this new custom activity.

Here’s the structure of the solution.


Benday.TeamBuild2010 contains the code to manipulate IIS.  Benday.TeamBuild2010.Activities contains the two Team Build Workflow Activities – IisDeleteWebApplication and IisCreateWebApplication.  Benday.TeamBuild2010.UnitTests contains the automated tests for the code.  Since the hard part of this project is interacting with IIS, the unit tests mostly focus on the IisUtility class in the Benday.TeamBuild2010 project.

In my actual build script, I dropped in a Sequence in the Compile and Test Sequence.  I named it Set Up IIS and this is where I put my calls to my custom activities.


Inside of the Set Up IIS Sequence, I put in calls to IisDeleteWebApplication and IisCreateWebApplication.  When I’m setting up an IIS application from inside of an automated build, I always call for a delete in order to make sure that I’m starting from a clean environment.  I want to make sure that there aren’t any weird settings hanging around when I create the web application.  I want to *know* exactly what I’m putting on IIS from my build in order to ensure that my build is accurate and repeatable.


The screenshot below is the Properties panel for the IisCreateWebApplication activity. 


Here are the properties for IisCreateWebApplication:

Name Description
ApplicationName Name of the application. 
ApplicationPath Location of the web application files on disk.
AppPoolName Name of the app pool that your application will run under.  If this value is blank, the default app pool will be used.
AuthenticationAnonymous Enables/disables anonymous authentication in the app.
AuthenticationBasic Enables/disables basic authentication in the app.
AuthentiationWindows Enables/disables Windows/NTLM authentication in the app.
SetAuthenticationSettings If this value is set to false, then the activity will not make any changes to the security configuration.  If true, the activity will update the security settings for the app.
SiteName Name of the website.  If this is blank, it will use the first website in the sites collection.  This is usually “Default Web Site”.


The following sites were essential for figuring out how to implement all this:
Editing IIS settings:
How to write to the TFS2010 Build Log & Manage Verbosity:
How to create an use a custom tfs build workflow activity:
What assemblies are required to make your builds compile in Visual Studio 2010:

The source code:

Click here to download the source code.  The zip contains two other zips: and  The first file contains all the source code.  The second file is a sample build script with all the required assembly references added to the project. 





— Want help customizing Team Foundation Server 2010?  Have some complex build scenarios that you want to implement?  Need training on how to use Team Foundation Server 2010 and Visual Studio 2010 Ultimate?  Interested in learning more about how to do Scrum with Team Foundation Server 2010?  Drop us a line at

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.