WiX EmbeddedChainer Examples?

半腔热情 提交于 2020-01-14 11:29:52

问题


With Windows Installer 4.5, there was a new table added for MsiEmbeddedChainer Table. This table was supposed to allow multiple-package installation. WiX added support for the table by creating the EmbeddedChainer element. I've read the wiki, but are there any examples on how to use the element?

I'm attempting to install a JRE before my program.


回答1:


Embedded chainers only work after the installer that contained them is installed, and can only install raw .msi files (.msi files with their own bootstrap .exe files cannot be used), so I don't think you'll be able to install the JRE the way you want.




回答2:


Do the following steps:

Changes in WXS file: ...

                    <Component DiskId="1" Guid="5CE59096-E197-4694-8DC2-E8EB4601C7C5" Id="CHAINERRUN.EXE">
                        <File Id="CHAINERRUN.EXE" Name="ChainerRun.exe" Source="..\ClinAppChainers\bin\ChainerRun.exe" />
                        <File Id="MICROSOFT.DEPLOYMENT.WINDOWSINSTALLER.DLL" Name="Microsoft.Deployment.WindowsInstaller.dll" Source="C:\Program Files\Windows Installer XML v3.6\SDK\Microsoft.Deployment.WindowsInstaller.dll" />
                        <File Id="MICROSOFT.CSHARP.DLL" Name="Microsoft.CSharp.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll" />
                        <File Id="SYSTEM.DLL" Name="System.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" />
                        <File Id="SYSTEM.CORE.DLL" Name="System.Core.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" />
                        <File Id="SYSTEM.XML.DLL" Name="System.Xml.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" />
                        <File Id="SYSTEM.XML.LINQ.DLL" Name="System.Xml.Linq.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll" />
                    </Component>

...

    <EmbeddedChainer Id="ChainerRun" FileSource="CHAINERRUN.EXE" />

The FileSource is the reference to the File element ID defined in the component

Create a C# project, reference to the file Microsoft.Deployment.WindowsInstaller.dll, or create a new WIX "C# Custom action project" then change the output to Console application EXE instead of DLL. The body of the CS file should contain the Main function

ChainerRun.CS

namespace ChainerRun 
{
    public class CustomActions
    {
      static void Main(string[] args)
      {
        System.Diagnostics.Debugger.Launch();

        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:\MyOtherApp.msi", argline);

            transaction.Commit();
            transaction.Close();

        }
        catch (Exception e)
        {
            throw e;
        }
    }

    [CustomAction]
    public static ActionResult CustomAction1(Session session)
    {
        System.Diagnostics.Debugger.Launch();
        session.Log("My CustomAction1() begins ...");
    }
}



回答3:


There is a bug in the c# code below: In the line "IntPtr ptr = new IntPtr(Convert.ToInt32(args[0], 16));" the "16" must be a "10"!

Otherwise you will get "bad handle" errors when there are more than 10 transactions (e.g. when there are five or more sub msi's called from the embedded chainer).




回答4:


The approach to embed the JRE as a package in a multi package transaction is an overkill which unnecessarily complicates maintenance.

There are two reasonable solutions with low maintenance.

  1. Use burn and install the JRE as a separate package in the bundle. Advantage of being able to use a prepared installation such as the ones from Oracle.
  2. The JRE by design is self versioned and requires no registrations or special handling, given that it may be best to include the jre in the main application MSI. This is a practice that I've seen in many professional java-based applications and has the added advantage of easily creating application shortcuts by referencing java.exe directly.


来源:https://stackoverflow.com/questions/5272718/wix-embeddedchainer-examples

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!