0 people following this project (follow)

There are three main steps needed to install a WCF LOB Adapter in a target machine:

1 – Copy adapter assemblies to the target machine.

2 – Install the adapter assemblies on the Global Assembly Cache.

3 – Register the adapter settings on the machine.config file.

In order to automate the mentioned steps you can either create a Visual Studio Installation Package or a Msbuild script. The first two steps are trivial and natively provided by the two mentioned approaches.

The last one deserves a bit more attention as custom logic needs to be built and performed. Initially, we need to understand what settings or xml elements/attributes are required to be created on the machine.config file, so the adapter is properly registered.

After understanding the requirements and implementing such logic, we need to either to have an Installation Package Custom Action or a Custom MSBuild Task to perform the steps.

If you choose the Installation Package as your deployment implementation, (Sonu’s Tech Blog, 2007) explains how to author the needed custom action.

However, if you would like to use MSBuild, the custom tasks: RegisterWCFLOBAdapter and UnregisterWCFLOBAdapter can be used in a MSbuild deployment script to perform the installation/uninstallation procedure.

The RegisterWCFLOBAdapter task can be used to register a WCF LOB Adapter through a MSBuild script as follows:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="InstallWCFLOBAdapter">

<UsingTask AssemblyName="WhiteboardWorks.MSBuild.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46c420b90a74da39" TaskName="RegisterWCFLOBAdapter" />

<Target Name="InstallWCFLOBAdapter">

<RegisterWCFLOBAdapter AdapterAssemblyName="MyAdapterAssembly, Version=1.0.0.0, Culture=neutral,PublicKeyToken=c3e07219674fce83" BindingScheme="myadapter" BindingElementName="myAdapterBinding" BindingType="WhiteboardWorks.Adapters.MyAdapter.MyAdapterBindingCollectionElement" BindingElementType="WhiteboardWorks.Adapters.MyAdapter.MyAdapterBindingElementExtensionElement" BindingName="myAdapterBinding" />


</Target>

</Project>

WCF LOB Adapter Full Installation Example:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="InstallWCFLOBAdapter">
<UsingTask AssemblyName="WhiteboardWorks.MSBuild.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46c420b90a74da39" TaskName="RegisterWCFLOBAdapter" />

<ItemGroup>
<WCFLOBAdapterDlls Include="*.dll"/>
</ItemGroup>

<PropertyGroup>
<InstallationFolder>c:\Test\</InstallationFolder>
</PropertyGroup>


<Target Name="InstallWCFLOBAdapter">

<Copy SourceFiles="@(WCFLOBAdapterDlls)" DestinationFolder="$(InstallationFolder)" />

<Exec Command="gacutil /i $(InstallationFolder)@(WCFLOBAdapterDlls->'%(Filename)%(Extension)')" />

<RegisterWCFLOBAdapter AdapterAssemblyName="MyAdapterAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c3e07219674fce83" BindingScheme="myadapter" BindingElementName="myAdapterBinding" BindingType="WhiteboardWorks.Adapters.MyAdapter.MyAdapterAdapterBindingCollectionElement" BindingElementType="WhiteboardWorks.Adapters.MyAdapter.MyAdapterAdapterBindingElementExtensionElement" BindingName="myAdapterBinding" />

</Target>
</Project>

The UnregisterWCFLOBAdapter task can be used to unregister a WCF LOB Adapter through a MSBuild script as follows:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="UninstallWCFLOBAdapter">
<UsingTask AssemblyName="WhiteboardWorks.MSBuild.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46c420b90a74da39" TaskName="UnregisterWCFLOBAdapter" />


<Target Name="UninstallWCFLOBAdapter">

<UnregisterWCFLOBAdapter BindingScheme="myadapter" BindingName="myAdapterBinding" BindingElementName="myAdapterBinding" />

</Target>
</Project>

WCF LOB Adapter Full Uninstallation Example:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="UninstallWCFLOBAdapter">


<UsingTask AssemblyName="RCCL.SOA.MSBuild.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46c420b90a74da39" TaskName="UnregisterWCFLOBAdapter" />

<ItemGroup>
<WCFLOBAdapterDlls Include="*.dll"/>
</ItemGroup>

<PropertyGroup>
<InstallationFolder>c:\Test\</InstallationFolder>
</PropertyGroup>

<Target Name="UninstallWCFLOBAdapter">
<UnregisterWCFLOBAdapter BindingScheme="myadapter" BindingName="myAdapterBinding" BindingElementName=" myAdapterBinding" />

<Exec Command="gacutil /u $(InstallationFolder)@(WCFLOBAdapterDlls->'%(Filename)%(Extension)')" />

<RemoveDir Directories="$(InstallationFolder)" />

</Target>
</Project>


For more information visit:

http://whiteboardworks.com/2010/02/installing-wcf-lob-adapters-with-msbuild/

Last edited Mar 24 2010 at 8:20 PM by brunospinelli, version 3

Comments

No comments yet.