Geeks With Blogs

News View Michael Stephenson's profile on BizTalk Blog Doc View Michael Stephenson's profile on LinkedIn

Michael Stephenson keeping your feet on premise while your heads in the cloud

A number of months ago I did a couple of posts about how we integrated the Soap and WSE web service publishing wizards into our build process as MsBuild tasks.  These posts are located at the following url's:

Soap Adapter:

WSE 2 Adapter:

Now that BizTalk 2006 R2 is around I want to have the same approach for the WCF Publishing Wizard.

Before I get into the details of this, it is important to note that WCF provides a hosting model that means you do not need to host services in IIS and they can be hosted by In Process BizTalk hosts.  Although this is cool, there are still a number of reasons you may still want to host the services in IIS. 


The aim of the task is to allow you to regenerate the services which are published as part of your build script.  This means if for example your schema changes then the published service is automatically updated for you each time you build the whole solution.  This also fits well with a continuous integration strategy.


The development process or approach I use in these situations is as follows:

1. The first time you produce the wcf service you will manually use the WCF Publishing Wizard and generate the service as desired. 

2. In the published service there is a temp file called WcfServiceDescription.xml.  Take a copy of this and add it as an item to your solution.

3. In your build script call the custom task we will create and pass in the path to the WcfServiceDescription.xml file in your solution.

In this process it is important to note that if you need to add any new schema or orchestrations to the published service you will need to generate the service again by hand to get in there new items, and then simply overwrite the description file in your solution.

Using the task

The following picture shows the sample of the build script using the task.

As you can see above the call to the task is very simple.

Inside the Task

The task itself is very simple and basically references the Microsoft.BizTalk.Adapter.Wcf.Publishing assembly and then executes the following code in the Execute method of the task.

Again the code is very simple

Things to watch for

There are a couple of things to watch for when you use this approach:

  • Ensure in the service description file you have the overwrite property set to true.  If not then if the service is already published you will get an error
  • I would also recomment setting up the application pool and virtual directory in IIS yourself as part of the build script.  This gives you full control over how it is created where as if you let the Wcf Service Publisher do it then it will use some default settings which you probably wouldnt want to use in practice


I hope you file this task useful, it is a little simpler that the previous ones, particularly the WSE 2 one which unfortunately had that bug we had to work around.  If you would like to check out the sample then see below where the source code is available.



I have noticed a few sites that seem to copy the content of blog articles and display them in their own site.  It is a bit annoying that they do not clearly reference or acknowledge the author so I have decided to put this note on the bottom of all of my posts from now so it is clear who wrote it.

This article was written by: Michael Stephenson

The source of this article is:

Posted on Sunday, February 3, 2008 6:12 PM BizTalk , MsBuild | Back to top

Comments on this post: MsBuild Task for WCF Service Publishing for BizTalk

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Stephenson | Powered by: