In one of my projects we expose schema’s as a WCF webservice. I wanted to use the BizTalk Deployment Framework to deploy the webservice along with all the other artifacts. Start by deploying the webservice using the BizTalk WCF Service Deployment Wizard. Once finished, copy the folder for the webservice from C:\inetpub\wwwroot to your project folder. After you have added the files to your project, make sure the build action on the XSD’s is set to None instead of BtsBuild, as the references in these schemas probably can’t be resolved on build. Now you have to make a couple changes in your BTDF project file. To start with, you will have to tell that you want to deploy virtual directories, change the following property to do so:
After the virtual directories have been created IIS has to be restarted. Luckily, this can also be done using BTDF, by setting the SkipIISReset property.
Next you will have to specify the settings of the webservice. For this create a new ItemGroup, which should be placed under the PropertyGroup with the ProductID.
<ItemGroup> <VDirList Include="*"> <Vdir>NameOfWebService</Vdir> <AppPool>NameOfAppPoolToRunServiceUnder</AppPool> <Physdir>..\NameOfWebserviceFolderYouCopiedEarlier</PhysDir> </VDirList> </ItemGroup>
You will also have to specify the user credentials the AppPool will run under. I used the SettingsFileGenerator.xml file for this. Add VDIR_UserName and VDIR_UserPass to this document, and set them for your environments. Now go back to the BTDF project file, and add the following under the ItemGroup you just created.
<ItemGroup> <PropsFromEnvSettings Include="VDIR_UserName;VDIR_UserPass" /> </ItemGroup>
Standard, the AppPool will be running .NET2, however we want it running .NET4. In the final release of BTDF v5 there will be a new attribute on the VDirList for this, but for now we have to use a CustomPostDeployTarget.
<Target Name="CustomPostDeployTarget"> <Exec Command=""C:\Windows\System32\inetsrv\appcmd.exe" set APPPOOL /apppool.name:"NameOfAppPoolToRunServiceUnder" /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated" /> </Target>
Now when you use the BTDF to deploy your application, it will automatically set up an AppPool and create the WCF webservice for you.