BTDF in Visual Studio 2015

4 minute read

Summary

The BizTalk Deployment Framework tool (BTDF) is a very useful tool for packaging up BizTalk applications for deployment to an environment. We have used it many times across various clients for all their BizTalk solutions and it works very well. (Especially for Octopus Deploy based automated deployments.)

Now with the release of BizTalk 2016, the IDE is now Visual Studio 2015.

IMPORTANT NOTE: There is now a BTDF V5.7 RC2 that has support for Visual Studio 2015. I would strongly recommend you check this out before reading the rest of this article.


BTDF is currently not fully supported in Visual Studio 2015. Yet.

So when then? There is now an RC1 of V5.7 of BTDF that is available here. Thomas is working away on completing functionality in this version.

So what can we do in the meantime?

If you are like us and about to start on BizTalk 2016 development and need the BTDF to work NOW, then follow the steps below.

There are some useful comments on the BTDF forums here. We used this as a base.

Pre-requisites

The following needs to be in place on your local developer VM first:

TIP: I had previously said you needed the Powershell GAC module. This is no longer required, however still recommended you download it as it is a very useful tool.

Installation Process

WARNING: This section was updated on 07/02/2017 when I found out that BTDF v5.7 RC1 was released.

Install the v5.7 RC1 of BTDF

Visual Studio 2015 usage

While the MSI is installed, its not integrated into Visual Studio 2015. So we will have to “kludge” that for now.

To do this, create your BizTalk Solution in Visual Studio 2015.

Add a solution Folder to the root of the Solution

Open the Package Manager Console inside of Visual Studio and run this PowerShell script.

TIP: You can get to the Package Manager Console by Tools-> Nuget Package Manager -> Package Manager Console

param (
    [Parameter(Mandatory)]
    [ValidateScript({Test-Path -Path $_ -PathType Container})] 
    [string] $BTDFTemplateFolder,

    [Parameter(Mandatory)]
    [string] $ParentSolutionFolder = "SolutionItems"
     )

# get the solution folder
$solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
$solutionFolder = Get-ChildItem -Path $solution.Filename | Select-Object -ExpandProperty DirectoryName

# Copy the Deployment folder from BTDF to the Solution folder
$deploymentSourceFolder = Join-Path -Path $BTDFTemplateFolder -ChildPath '\Deployment'

if ((Test-Path -Path $deploymentSourceFolder) -eq $false)
{
    Write-Error "Unable to find the path $deploymentSourceFolder. Check the parameters and try again." -ErrorAction Stop
}
Write-Host "Copying BTDF Template to the Solution..."
Copy-Item -Path $deploymentSourceFolder -Destination $solutionFolder -Recurse

$targetDeploymentFolder = "$solutionFolder\Deployment"
Write-Host "Target Deployment Folder is: $targetDeploymentFolder"

Write-Host "Updating Deployment.btdfproj file for this solution..."
$solutionName = $solution.Properties | Where-Object Name -eq "Name" | Select-Object -ExpandProperty Value
$newGuid = New-Guid | Select-Object -ExpandProperty Guid
[xml] $configFile = Get-Content "$targetDeploymentFolder\Deployment.btdfproj"
# update the handful of fields that can be updated
$configFile.Project.PropertyGroup[0].ProjectName = "$solutionName"
$configFile.Project.PropertyGroup[1].ProductName = "$solutionName for BizTalk"
$configFile.Project.PropertyGroup[1].PackageComments = "$solutionName"
$configFile.Project.PropertyGroup[1].PackageDescription = "$solutionName"
$configFile.Project.PropertyGroup[1].ProductUpgradeCode  = "$newGuid"
$configFile.Save("$targetDeploymentFolder\Deployment.btdfproj")

# get the solution items folder
Write-Host "Creating Solution Folders and adding files..."
$solutionItemsProject =$solution.Projects | Where ProjectName -eq $ParentSolutionFolder
$solutionItemsInterface = Get-Interface $solutionItemsProject.Object ([EnvDTE80.SolutionFolder])

# add the deployment folder and its subfolder Environment Settings
$deploymentFolder = $solutionItemsInterface.AddSolutionFolder("Deployment")

$deploymentFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\BizTalk2016MSI.wxs") | Out-Null
$deploymentFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Deployment.btdfproj") | Out-Null
$deploymentFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\InstallWizard.xml") | Out-Null
$deploymentFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\License.rtf") | Out-Null
$deploymentFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\PortBindingsMaster.xml") | Out-Null
$deploymentFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\UnInstallWizard.xml") | Out-Null

$deploymentInterface = Get-Interface $deploymentFolder.Object ([EnvDTE80.SolutionFolder])
$envSettingsFolder = $deploymentInterface.AddSolutionFolder("EnvironmentSettings")
$commandsFolder = $deploymentInterface.AddSolutionFolder("Commands")

$envSettingsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\EnvironmentSettings\SettingsFileGenerator.xml") | Out-Null

$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Bounce BizTalk.cmd") | Out-Null
$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Build MSI.cmd") | Out-Null
$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Deploy.cmd") | Out-Null
$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Export Settings.cmd") | Out-Null
$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Quick Deploy Orch.cmd") | Out-Null
$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\UnDeploy.cmd") | Out-Null
$commandsFolder.ProjectItems.AddFromFile("$targetDeploymentFolder\Update SSO.cmd") | Out-Null

#Save the solution
$solution.SaveAs($solution.FullName)

Use the following parameters

  1. BTDFTemplateFolder - same as the parameter above
  2. ParentSolutionFolder - name of the parent solution folder. I used “solutionItems”. Your standard might be something else.

This will copy files from the Workaround folder to your solution, add them to the Solution Folder. The Deployment.btdfproj file is also updated with the name of the Solution and the GUIDS are generated.

TIP: If you prefer the Visual Studio structure to be different, feel free to edit the script above.

How to use it?

The commands folder (highlighted in yellow above) work as a way to call the BTDF commands that would have appeared in the toolbar.

If you have an extension (like Command Line) that allows for executing of cmd files, you can right click and run the commands.

The next step is to edit the Deployment.btdfproj file as per your usual process.

NOTE: This is still intended as a temporary fix until an official version of BTDF with Visual Studio 2015 support is released!

Shout out to Paul Nichols, a fellow Mexian who did some work on this as well :)

If there are any issues with this or you can think of some improvements, please let me know.

Leave a Comment