This project has moved and is read-only. For the latest updates, please go here.

How to use PublishWcfServiceArtifacts

Topics: IIS and Web Services
Apr 5, 2014 at 1:53 PM

We are starting to use BTDF, and are currently trying to figure out exactly how to deploy our BizTalk Web Service endpoints with BTDF, we have created the WCF services with the WCF wizard but just can't figure out what we need to add to the BizTalk Solution and to the BTDFPROJ file.

Where can we find some examples?

How can we use the new PublishWcfServiceArtifacts feature added in 5.5?

Bill Chesnut
Apr 7, 2014 at 6:56 AM
Hi Bill,

Now that you have exported the service, you should move the entire web service project folder from wwwroot to your BizTalk solution folder next to your schemas, maps, etc. project folders. Then you can just Add Existing Project to add the web service project into the BizTalk solution.

Next, use the VdirList ItemGroup to configure an IIS AppPool pointing to the service folder (path will usually then be similar to ..\MyWCFService). The Advanced sample application does not use a WCF service, but does use the VdirList ItemGroup.

The PublishWcfServiceArtifacts goes into the web service .csproj. You'll need a UsingTask to bring in the task and the call to the task in the AfterBuild target.
<UsingTask TaskName="DeploymentFramework.BuildTasks.PublishWcfServiceArtifacts" AssemblyFile="BizTalkDeploymentFramework.Tasks.dll" />

<Target Name="AfterBuild">
  <PublishWcfServiceArtifacts ServiceDescriptionPath="Definition\WcfServiceDescription.xml" OutputPath=".\" />
The BizTalk WCF service export wizard creates a definition file called WcfServiceDescription.xml, which captures the settings used in the wizard. The file is saved to App_Data\Temp. The task requires this definition file to reproduce the original export. There are only four files that should be preserved in source control from the published service: [service].svc and web.config and the service description and binding XML files in App_Data\Temp. Everything in App_Data itself can be recreated with this task.

Apr 9, 2014 at 11:43 PM

I have the solution checked into TFS and when I try to do a local deploy I get:

C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1748,5): error MSB3073: The command "cacls "..\SolutionItems\WebServices\BizTalkDemo.Process1" /E /G bill.chesnut:R" exited with code 13. [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]

My Setup is:
Solution 'BizTalkDemo'

    <VDirList Include="*">

  <UsingTask TaskName="DeploymentFramework.BuildTasks.PublishWcfServiceArtifacts" AssemblyFile="BizTalkDeploymentFramework.Tasks.dll" />

  <Target Name="AfterBuild">
    <PublishWcfServiceArtifacts ServiceDescriptionPath="..\SolutionItems\WebServices\BizTalkDemo.Process1\App_Data\Temp" OutputPath=".\" />
if I add
I get:

C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: The "CreateVirtualDirectory" task failed unexpectedly. [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7) [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: at System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsContainer.Create(String className, String relativeName) [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName) [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: at DeploymentFramework.BuildTasks.CreateVirtualDirectory.Execute() [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1754,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() [C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj]
Done Building Project "C:\Mexia\Mexia\Demos\BizTalkDemo\Deployment\Deployment.btdfproj" (Deploy target(s)) -- FAILED.
Apr 10, 2014 at 3:16 AM
Working Fine now, IIS has some leftover artifacts that was causing the issue.
Apr 10, 2014 at 3:31 AM
Edited Apr 10, 2014 at 3:32 AM
Hi Bill, do you specify the full path to the wcfservicedescription file, or just to the folder it is in?

<PublishWcfServiceArtifacts ServiceDescriptionPath="..\SolutionItems\WebServices\BizTalkDemo.Process1\App_Data\Temp" OutputPath=".\" />

Don't you need to add the filename? As in ...
<PublishWcfServiceArtifacts ServiceDescriptionPath="..\SolutionItems\WebServices\BizTalkDemo.Process1\App_Data\Temp\WCFServiceDescription.Xml" OutputPath=".\" />

Also - you are overwriting the WCFServiceDescription.xml file while creating the service, maybe the MSBuild task can't handle this? I would try storing the WCFServicedescription file as a Template somewhere else outside the Vdir folder and build the service from that.
Apr 10, 2014 at 3:35 AM
Did you ever get it to work without the

<ModifyNTFSPermissionsOnVDirPaths>False</ModifyNTFSPermissionsOnVDirPaths ?

I am having that issue with cacls returning code 13 as well.
Apr 10, 2014 at 3:55 AM
Yes, change the virtual directory name, then created a virtual directory with the name I wanted pointing to the same location, then changed the btdfproj file back to the original name an everything worked.
Apr 10, 2014 at 4:43 AM
Larswa, ServiceDescriptionPath should include the filename. It's normal to keep the description file under the web service project folder. Error code 13 is "invalid data". It could be due to a non domain-qualified username, but hard to say. cacls is very picky.

Apr 22, 2014 at 7:21 AM
When I ran deployments in BTDF Version 5.5 based on this forum post, it seemed to be skipping over the <Target Name="AfterBuild"> part.

After checked the documentation for BTDF 5.5 (List of Targets page) I changed my XML to be:
  <UsingTask TaskName="DeploymentFramework.BuildTasks.PublishWcfServiceArtifacts" AssemblyFile="BizTalkDeploymentFramework.Tasks.dll" />
  <Target Name="CustomPostDeployTarget">
    <PublishWcfServiceArtifacts ServiceDescriptionPath="..\SolutionItems\WebServices\Service\App_Data\Temp\WcfServiceDescription.xml" OutputPath="..\SolutionItems\WebServices\Service" />
I also had to update the OutputPath to ensure the generated data was outputted to the correct folder.

Is this suitable?
Apr 22, 2014 at 7:25 AM
While there is nothing preventing you from using the PublishWcfServiceArtifacts task in the .btdfproj, it was really designed to be used inside the service's .csproj. The AfterBuild target is used by C# projects. That way every time you build the service project you'll get the exported artifacts.

Apr 22, 2014 at 8:22 AM
We don't have .csproj files we have .btproj files, assuming that it will work in them also?

if we did decide to do the in the .btdfproj file, what would the best target to use 'CustomPostDeployTarget' or something else?

Apr 22, 2014 at 4:19 PM
Yes, it will work in a .btproj since that is just an enhanced .csproj. I put this at the end of a .btproj before </Project> and it printed the message during the build, so you can definitely put the PublishWcfServiceArtifacts task there.
  <Target Name="AfterBuild">
    <Message Text="In AfterBuild" />

It's more work to put it in the .btdfproj, because you'll have to handle service publishing during the MSI build as well as during deployment. You'd have to use the CustomRedist target to export and copy the files into the $(RedistDir) path for the MSI.