I wrote this little utility almost 2 years ago to speed up deployment and binding, enlisting, enabling and starting BizTalk components in a development environment and then to perform the uninstall. It works well on simple BizTalk projects. With more complex BizTalk projects I would recommend using Nant. My colleges and I now never use msi’s for installs\uninstalls as they are harder to debug when a deployment fails and less configurable than Nant which is also open source. I know my posting of this is a little late as it’s now easier to perform these functions in BizTalk 2006, sorry been busy.


The utility generates install and uninstall bat files for a BizTalk assembly applying a config file. The bat files call the btsdeploy utility and the vb scripts located in the BizTalk sdk directory (C:\Program Files\Microsoft BizTalk Server 2004\SDK\Samples\Admin\WMI\) to deploy, bind, enlist, enable and start up BizTalk orchestrations and the uninstall will do the reverse. Below is the usage message for this command line utility.


Generates an install bat file and an uninstall bat file for BizTalk Assemblies.
Syntax: BizBatInstall {Commands}
Commands:
        /b    Binding config file must be used with /a /i or /a /u
        /a    BizTalk assembly file must be used with /b /i or /b /u
        /i    Install bat file to generate must be used with /b /a
        /u    Uninstall bat file to generate must be used with /b /a
        /? or /help     Display this usage message


To create the utility:


1) In Visual Studio create a C# Console app call it BizBatInstall


2) Replace all the generated code in the class file with the following…


using System;
using System.IO;
using System.Configuration;
using System.Xml;


namespace Synergy.Samples
{
 ///


 /// Summary description for Class1.
 ///

 class BizBatInstall
 {
  ///
  ///The main entry point for the application.
  ///Gets the name of the assemblies and bat files
  ///Generates an install bat file and an uninstall bat file
  ///Install bat file contents:
  /// Rebuilds assembly
  /// Deploys assembly
  /// Imports the binding file
  /// Starts the send ports
  /// Enlists the orchestration
  /// Enables the recieve locations
  ///
  ///Uninstall bat file contents:
  /// Stops the orchestration
  /// Undeploys the biztalk assembly
  /// Removes the recieve ports
  /// Removes the send ports
  ///

  [STAThread]
  static void Main(string[] args)
  {
   try
   {
    //Check for help
    if (args.Length == 0)
    {
     ShowUsageMessage();
    }
    
    else if((args[0] == “/?”) || (args[0] == “/help”))
    {
     ShowUsageMessage();
    }


    else
    {
     //Parse out command line arguements
     string bindingFileName = GetCommand(“/b”, args);
     string assembly = GetCommand(“/a”, args);
     string uninstallBatFileName = GetCommand(“/u”, args);
     string installBatFileName = GetCommand(“/i”, args);


     if (bindingFileName != string.Empty && assembly != string.Empty)
     {
      //Load the binding config file into an xml doc
      XmlDocument bindingDoc = new XmlDocument();
      bindingDoc.Load(bindingFileName);


      //Generate the bat files
      GenerateInstallBat(installBatFileName, bindingFileName, assembly, bindingDoc);
      GenerateUninstallBat(uninstallBatFileName,bindingFileName, assembly, bindingDoc);
     }


     else
     {
      Console.WriteLine(“The binding file and or assembly file command line arguements were not set, no install or uninstall bat files generated!”);
     }
    }
   }
   catch (System.Exception ex)
   {
    Console.Write(ex.ToString());
   }
  }


  private static string GetCommand(string commandToken, string[] args)
  {
   string commandValue = string.Empty;


   for (int i = 0; i < args.Length; i++)
   {
    if (args[i] == commandToken)
    {
     commandValue = args[i + 1];
     break;
    }
   }
   return commandValue;
  }


  private static void ShowUsageMessage()
  {
   Console.WriteLine(“Generates an install bat file and an uninstall bat file for BizTalk Assemblies.”);
   Console.WriteLine(“Syntax: BizBatInstall “);
   Console.WriteLine(“Commands:”);
   Console.WriteLine(“\t/b \tBinding config file must be used with /a /i or /a /u”);
   Console.WriteLine(“\t/a \tBizTalk assembly file must be used with /b /i or /b /u”);
   Console.WriteLine(“\t/i \tInstall bat file to generate must be used with /b /a”);
   Console.WriteLine(“\t/u \tUninstall bat file to generate must be used with /b /a”);
   Console.WriteLine(“\t/? or /help \tDisplay this usage message”);
  }


  private static void GenerateUninstallBat(string uninstallBatFileName, string bindingFileName,
   string biztalkAssemblyFileName, XmlDocument bindingDoc)
  {
   if (uninstallBatFileName != string.Empty)
   {
    try
  &nb