I was recently asked to create a secure FTP adapter for BizTalk.
I created it and tested it. I then went to create the install package.
The issue is I needed to determine where BizTalk is installed and put the assemblies in that directory and write where I put those assemblies into the registry.
Here are the steps to make the MSI ‘smart’
- Open the Launch Conditions by right clicking on the Setup project View – Launch Conditions
- Right click on the Search Target Machine folder and click Add Registry Search
- In the properties, add the following values
(Name) BizTalk Install Path Property BIZTALKINSTALLPATH RegKey SOFTWARE\Microsoft\BizTalk Server\3.0 Root vsdrrHKLM Value InstallPath We are going to use this value BIZTALKINSTALLPATH thru the rest of the process
- Now we need to add the entries to the registry. We do this by right clicking on Setup project View – Registry (like step 1) and click Import
and import the registry file created from the Adapter Registry Wizard
- Now edit the locations that have the path hard coded
- Now we need to add the directory where BizTalk is installed for us to put the assemblies there, in File System (right click Setup – View File System), right click and Add Special Folder
with the following properties
(Name) BizTalk Folder Always Create False Condition DefaultLocation [BIZTALKINSTALLPATH]\ Property NEWPROPERTY1 Transitive False - In your BizTalk folder, add the assemblies you want to install
- Now we want the MSI to not only install the adapter, but also make sure that it is in the adapter list. We do this by executing the following VB script code, we want to make sure that the strAdapterMgmtCLSID in the script matches the entry in the registry and add it to the Application Folder.
'AddAdapter.vbs 'Adds adapter to BizTalk strAdapterName = "sFTP" strAdapterComment = "FTP using SSL" strAdapterMgmtCLSID = "{AC6145E9-44C2-4C3F-AC3A-D207C9E99B87}" AddAdapter strAdapterName, strAdapterComment, strAdapterMgmtCLSID Sub AddAdapter(strAdapterName, strAdapterComment, strAdapterMgmtCLSID) Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objService = objLocator.ConnectServer("localhost", "root/MicrosoftBizTalkServer") Set objAdapterClass = objService.Get("MSBTS_AdapterSetting") On Error Resume Next Set objAdapterInstance = objService.Get("MSBTS_AdapterSetting.Name='" & strAdapterName & "'") If (objAdapterInstance is Nothing) Then On Error Goto 0 Set objAdapterInstance = objAdapterClass.SpawnInstance_ Else On Error Goto 0 End If objAdapterInstance.Name = strAdapterName objAdapterInstance.Comment = strAdapterComment objAdapterInstance.MgmtCLSID = strAdapterMgmtCLSID On Error Resume Next objAdapterInstance.Put_(0) If (Err.Number <> 0) Then Else End If End Sub
- Now we simply need to add it as a custom action, we right click the project again View-Custom Actions, we want to make sure it is done after the registry is made, so lets put this in the Commit, right click and browse to the Application Folder and select OK.
It should look like this
You are ready to go!