How to fix or configure the Deployment Properties of a Visual Studio BizTalk Project with PowerShell version 2

It is nothing new that before you can deploy a solution from Visual Studio into a BizTalk application, you must first set project properties, especially the Server and the Configuration Database. Otherwise, two things may happen:

  • The deployment will fail when you try to do to deploy it through Microsoft Visual Studio or will you are redeploying a previously deployed BizTalk project.
  • The assemblies and all their artifacts will be deployed to and unwanted BizTalk Application (normally BizTalk Application 1)

Previously I wrote a post regarding how to fix the Deployment Properties of a Visual Studio BizTalk Project with PowerShell, you can know more about it here. However, during my talks about tips and tricks I realize that the previous script was a little limited, it only worked if the deployment properties already exist in the file. This means that, if we were working on a new project or we obtaining a copy of the project from the source control, the script didn’t correctly set up or fix the deployment settings.

I promised that I would fix it and now I’m keeping my word. And I have to say that, this is probably one of the scripts that I use the most, and the reason why is…

So, why this script is important?

Well, if a solution in Visual Studio contains multiple projects, you need to manually configure the deployment properties for each project.

And you must keep in mind that these settings are under the Project User Options file(s) (“*.btproj.user”) that are typically not under source control. The reason is that the Visual Studio deployment feature main focus is for development scenarios where one user settings might differ from another. And it will be up to you, or your client, to decide if you want these files to be checked in and available to all of the developers on your team. (you can read it more about this here)

So, this seems a slight and easy task but now imagine that you have almost 200 projects inside a unique Visual Studio Solution! It will be an insane and consuming task to do and most likely to happen is you to fall asleep in front of the PC.

With this PowerShell, you will be able to parameterize all projects inside a Visual Studio Solution running a single line of code and avoid spending numerous hours doing this task manually.

PowerShell script overview

    $allPropertyGroup = $xml.Project.PropertyGroup
    foreach($node in $allPropertyGroup)
        if($node.Server -ne $null)
            #If the Deployment Setting already exists, then we just need to update them
            $addNewNodeFlag = $false
            $node.Server= $ServerName;
            $node.ConfigurationDatabase= $DatabaseName;
            $node.ApplicationName= $ApplicationName;
            $node.Redeploy= $RedeployFlag;
            $node.Register= $RegisterFlag;
            $node.RestartHostInstances= $RestartHostInstancesFlag;

    if($addNewNodeFlag -eq $true)
        #Add a PropertyGroup node if the Deployment Setting doesn't exist
        $newXmlPropertyGroup = $xml.CreateElement("PropertyGroup", "")
        $newXmlPropertyGroup.SetAttribute(“Condition”,”'`$(Configuration)|`$(Platform)' == 'Debug|AnyCPU'”);

        $newXmlElement = $newXmlPropertyGroup.AppendChild($xml.CreateElement("Server", ""));
        $newXmlTextNode = $newXmlElement.AppendChild($xml.CreateTextNode($ServerName));

        $newXmlElement = $newXmlPropertyGroup.AppendChild($xml.CreateElement("ConfigurationDatabase", ""));
        $newXmlTextNode = $newXmlElement.AppendChild($xml.CreateTextNode($DatabaseName));

        $newXmlElement = $newXmlPropertyGroup.AppendChild($xml.CreateElement("ApplicationName", ""));
        $newXmlTextNode = $newXmlElement.AppendChild($xml.CreateTextNode($ApplicationName));

        $newXmlElement = $newXmlPropertyGroup.AppendChild($xml.CreateElement("Redeploy", ""));
        $newXmlTextNode = $newXmlElement.AppendChild($xml.CreateTextNode($RedeployFlag));

        $newXmlElement = $newXmlPropertyGroup.AppendChild($xml.CreateElement("Register", ""));
        $newXmlTextNode = $newXmlElement.AppendChild($xml.CreateTextNode($RegisterFlag));

        $newXmlElement = $newXmlPropertyGroup.AppendChild($xml.CreateElement("RestartHostInstances", ""));
        $newXmlTextNode = $newXmlElement.AppendChild($xml.CreateTextNode($RestartHostInstancesFlag));

        $xml.Project.InsertAfter($newXmlPropertyGroup, $xml.Project.PropertyGroup[1])



You can download the PowerShell Script used from GitHub here:

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

3 thoughts on “How to fix or configure the Deployment Properties of a Visual Studio BizTalk Project with PowerShell version 2”

  1. Hi,

    I don’t seem to be able to find this script at the specified location. Do you know if it was moved somewhere else?

    Thank you,

    1. Hi Sergio,
      I need to update all my links. TechNet Gallary is deprecated.
      I update the link to the new GitHub repository where I have all my resources

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to Top