BizTalk Export MSI and Binding files to a Folder programmatically C#

Many times as developers we may need to export Binding files and MSIs in bulk for all the applications especially in case of any major update to keep as backup or DR scenarios.

I have written a utility to achieve this, hope it helps.

This utility uses “BTSTask.exe” to export MSIs and Bindings by calling it from cmd.exe.

Export Binding Files –

private static void exportBindingFile(string strApplicationName)
                string strBindingFile = string.Format("{0}\\{1}{2}", strExportFolder, strApplicationName, strBindingPostFix);
                string exportArgumentsBindings = string.Format("ExportBindings -Destination:\"{0}\"  -ApplicationName:\"{1}\"", strBindingFile, strApplicationName);
                exceuteCommand(strBTSTaskCMD, exportArgumentsBindings);

Export MSIs –

private static void exportMSIFile(string strApplicationName)
           string strMSIFile = string.Format("{0}\\{1}{2}", strExportFolder, strApplicationName, strMSIPostFix);
           string exportArgumentsMSIs = string.Format("ExportApp -Package:\"{0}\"  -ApplicationName:\"{1}\"", strMSIFile, strApplicationName);
           exceuteCommand(strBTSTaskCMD, exportArgumentsMSIs);

Function to execute this command using cmd.exe –

private static int exceuteCommand(string command, string arguments)
                Process process = new Process();
                process.StartInfo.FileName = command;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.Arguments = arguments;
                string stdout = process.StandardOutput.ReadToEnd();
                var exitCode = process.ExitCode;
                logMsg(string.Format("ExitCode: {0}", exitCode));
                logMsg(string.Format("Response: {0}", stdout));
                if (exitCode == 0)
                    logMsg("Command executed successfully");
                    logMsg("Command execution failed");
                return exitCode;
            catch (Exception excep)
                strFunctionName = "exceuteCommand";
                string strExceptionMessage = " - An exception occurred in Function - " + strFunctionName + ". " + Environment.NewLine + "Message - " + excep.Message;
                throw new Exception(strExceptionMessage);

Hope it’s helpful.

Download the complete code from here

Contact Me:- 

@Gmail@Facebook @Twitter@LinkedIn@MSDNTechnet@My Personal Blog 


One thought on “BizTalk Export MSI and Binding files to a Folder programmatically C#”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s