使用嵌入式EmbeddedChainer安装多个MSI

时间:2012-04-25 17:44:39

标签: wix windows-installer

我正在尝试使用Windows Installer Embedded链安装多个.msi。我从一个网站上研究了一些信息,然后我试了一下。但它不起作用( WiX + C#)。

  1. 当我检查调试时,它会成功运行,直到transaction.Commit()transaction.close()。但是SampleApp.msi没有安装。
  2. 即使SampleApp.msi不起作用,也安装了“多个MIS安装程序”,我无法卸载“多个MIS安装程序”。错误日志中的条目是“安装期间发生致命错误”。
  3. 我该如何解决?

    多个MSIs Installer \ Product.wxs

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="Multiple Installer">
                <Component Id="InstallMSIComponent" Guid="{7091DE57-7BE3-4b0d-95D5-07EEF6463B62}">
                    <File Id="FILE_MprjChainer.exe" Name="MprjChainer.exe"
                          Source="C:\A_VS2008\WiX\MprjChainer\MprjChainer\bin\Debug\MprjChainer.exe"
                          DiskId="1" KeyPath="yes"/>
                    <File Id="Microsoft.Deployment.WindowsInstaller.dll"
                          Name="Microsoft.Deployment.WindowsInstaller.dll"
                          Source="C:\Program Files\Windows Installer XML v3.5\SDK\Microsoft.Deployment.WindowsInstaller.dll" />
                    <File Id="System.dll"
                          Name="System.dll"
                          Source="C:\windows\Microsoft.NET\Framework\v2.0.50727\System.dll" />
                    <File Id="System.Core.dll" Name="System.Core.dll"
                          Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" />
                    <File Id="System.Windows.Forms.dll" Name="System.Windows.Forms.dll"
                           Source="C:\windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll" />
                    <File Id="System.Xml.dll"
                          Name="System.Xml.dll"
                          Source="C:\windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll" />
                    <File Id="System.Xml.Linq.dll"
                          Name="System.Xml.Linq.dll"
                          Source="c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" />
                    <RemoveFolder Id="INSTALLLOCATION" On="uninstall"/>
                </Component>
    
                <Component Id="CMPG_SimpleApp" Guid="{CB568AA4-9790-4efd-91BB-82682F063321}">
                    <File Id="SimpleApp.msi"
                          Name="SimpleApp.msi"
                          Source="C:\A_VS2008\WiX\MSIs\SimpleApp.msi"
                          DiskId="1" KeyPath="yes"/>
                </Component>
            </Directory>
        </Directory>
    </Directory>
    
    <EmbeddedChainer Id="Chainer" FileSource="FILE_MprjChainer.exe"/>
    
    <Feature Id="ProductFeature" Title="MPrjInstaller" Level="1">
        <ComponentRef Id="InstallMSIComponent"/>
        <ComponentRef Id="CMPG_SimpleApp"/>
        <ComponentGroupRef Id="Product.Generated" />
    </Feature>
    

    Chainer \ CustonAction.cs

    namespace MprjChainer
    {
        public class CustomActions
        {
            static void Main(string[] args)
            {
                System.Diagnostics.Debugger.Launch();
    
                try
                {
                    IntPtr ptr = new IntPtr(Convert.ToInt32(args[0], 16));
                    Transaction transaction = Transaction.FromHandle(ptr, true);
    
                    transaction.Join(TransactionAttributes.JoinExistingEmbeddedUI);
    
                    transaction.Commit();
                    transaction.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show("e.Message; " + e.Message);
                    throw e;
                }
            }
    
            [CustomAction]
            public static ActionResult CustomAction1(Session session)
            {
                System.Diagnostics.Debugger.Launch();
                session.Log("Begin CustomAction1");
    
                return ActionResult.Success;
            }
        }
    }
    

2 个答案:

答案 0 :(得分:0)

尝试调用InstallProduct():

transaction.Join(TransactionAttributes.JoinExistingEmbeddedUI);

// start another installation in the same transaction
Installer.InstallProduct(@"path_To_Your_MSI", arguments);   
// it's good to include /l*v install.log in the arguments so that you'll get a verbose log of the installation

transaction.Commit();

可以在WiX EmbeddedChainer Examples?

看到Embedded Chainer的示例

您还可以查看Burn(来自Wix的bootstrapper / chainer)链接多个msi包:http://robmensching.com/blog/posts/2009/7/14/Lets-talk-about-Burn

答案 1 :(得分:0)

c#代码中有一个错误: 在“IntPtr ptr = new IntPtr(Convert.ToInt32(args [0],16))”行中;“ “16”必须是“10”!

否则,当有超过10个事务时(例如,当从嵌入式chainer中调用五个或更多个子msi时),您将收到“错误处理”错误。