112417_1021_Authenticat1.png

The BTSWCFServicePublishing tool

The basis for this post is mostly to serve as a reminder of the steps you need to go thru to use this tool.

Usage and why

Why do I need this tool? It is simply put the best way to deploy WCF-services on the local IIS and even if the BtsWcfServicePublishingWizard.exe can do it on the dev machine, you still have to deploy the service on the QA and Prod machines. Also it automates the deployment process as all that is needed is the WcfServiceDescription-file generated by the Wizard.

So in short: use the BtsWcfServicePublishingWizard.exe on the dev box and the BTSWCFServicePublishing tool on all the others.

Getting the tool

The tool is strangely not a part of the BizTalk deployment. You have to download and install it separately. The tool can be downloaded here. The package is a self-extracting zip. Just unpack it at a location of choice. I usually have a “Tools”-folder somewhere.

Configuring the tool

I don’t know why but Microsoft left some configuration out when publishing this download. In order to make the tool work on BizTalk 2013 and 2013R2-versions you have to update the configuration to use version 4.0 of the .net framework, otherwise it will not be able to use the BizTalk schema DLL:s as intended. The fix is simple though. Just open the BtsWcfServicePublishing.exe.config from the newly extracted package and add the following settings at the top, just under the configuration-tag.

<startup
useLegacyV2RuntimeActivationPolicy=true>

<supportedRuntime
version=v4.0 />

</startup>

Now the tool will work properly. If you don’t do this the error Error publishing WCF service. Could not load file or assembly ‘file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\ProjectName\v4.0_1.0.0.0__keyhere\ProjectName.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

(Side note: The “-signs in the xml above can be jumbled due to the blog’s theme. Just make sure they are the straight kind).

Running the tool

Simple as can be. Open a cmd-promt run the program and give it the WcfServiceDescription.xml file as input. The program will deploy the website/service as configured in the file.

This file is located under the App_Data/Temp folder when you use the BtsWcfServicePublishingWizard to publish the site locally.

More information

A command-line reference can be found here.