Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install two MSI packages with single MSI package using WIX?

I have a scenario to install two MSI packages with single MSI package.

For example we have two products to install viz. Sample1.MSI and Sample2.MSI. We need to embed Sample2.MSI package into Sample1.MSI. If we install Sample1.MSI it should install both Sample1.MSI and Sample2.MSI and this should create two entries in Add or Remove programs (appwiz.cpl).

After a search I found a sample app which is using 'EmbeddedChainer' tag which is working properly with installation. But it is not uninstalling properly.

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="SampleSetup">

      <Component Id="InstallMSIComponent" Guid="{7091DE57-7BE3-4b0d-95D5-07EEF6463B62}">
        <File Id="ChainRunner.exe" Name="ChainRunner.exe"
              Source="C:\ChainRunner.exe"
              DiskId="1" KeyPath="yes"/>
        <File Id="TestFile.txt" Name="TestFile.txt" Source="TestFile.txt" />
        <File Id="Microsoft.Deployment.WindowsInstaller.dll" Name="Microsoft.Deployment.WindowsInstaller.dll" Source="C:\Microsoft.Deployment.WindowsInstaller.dll"/>
        <File Id="Microsoft.Deployment.WindowsInstaller.xml" Name="Microsoft.Deployment.WindowsInstaller.xml" Source="C:\Microsoft.Deployment.WindowsInstaller.xml"/>          
        <RemoveFolder Id='INSTALLLOCATION' On='uninstall' />
      </Component>

      <Component Id="SampleSetup2Component" Guid="{CB568AA4-9790-4efd-91BB-82682F063321}">
        <File Id="SampleSetup2.msi" Name="SampleSetup2.msi"
              Source="SampleSetup2.msi"
              DiskId="1" KeyPath="yes"/>      
      </Component>
            </Directory>
        </Directory>
    </Directory>
<EmbeddedChainer Id="Chainer" FileSource="ChainRunner.exe"/>

    <Feature Id="ProductFeature" Title="SampleSetup" Level="1">

  <ComponentRef Id="InstallMSIComponent"/>
  <ComponentRef Id="SampleSetup2Component"/>

        <ComponentGroupRef Id="Product.Generated" />
    </Feature>

ChainRunner code

public class CustomActions
{

    static void Main(string[] args)
    {

        try
        {
            IntPtr ptr = new IntPtr(Convert.ToInt32(args[0], 16));
            ptr = System.Runtime.InteropServices.Marshal.StringToCoTaskMemAuto(args[0]);
            Transaction transaction = Transaction.FromHandle(ptr, true);
            transaction.Join(TransactionAttributes.JoinExistingEmbeddedUI);

            Installer.InstallProduct(@"C:\SampleSetup2.msi", "");
            transaction.Commit();
            transaction.Close();
        }
        catch (Exception e)
        {

            Console.WriteLine("Exception in Installation:"+e.Message+"\n"+e.StackTrace.ToString());
            Console.ReadKey();
            throw e;
        }
    }
    [CustomAction]
    public static ActionResult CustomAction1(Session session)
    {
        session.Log("Begin CustomAction1");

        return ActionResult.Success;
    }
}

Where the this has been messed up?

Please advice if there is any other best way other than this approach?

like image 298
DBalaji Avatar asked Jan 24 '26 00:01

DBalaji


1 Answers

You can use Wix Burn to create a setup package contained multiple application installers:

  • Wix Toolset: Building Installation Package Bundles;
  • Neil Sleightholm's Blog: WiX Burn – tips/tricks.
like image 159
vemcaster Avatar answered Jan 26 '26 13:01

vemcaster