0

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

  1. 当我检查调试时,它可以成功运行,transaction.Commit()直到transaction.close(). 但是SampleApp.msi没有安装。
  2. 'Multiple MISs Installer' 安装成功,即使SampleApp.msi没有工作,我也无法卸载'Multiple MISs Installer'。错误日志中的条目是“安装过程中的致命错误”。

我如何解决它?

多个 MSI 安装程序\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;
        }
    }
}
4

2 回答 2

0

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

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

于 2013-08-08T09:56:26.770 回答
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();

Embedded Chainer 的示例可以在以下位置查看: WiX EmbeddedChainer 示例?

您还可以查看用于链接多个 msi 包的 Burn(Wix 的引导程序/链接器):http ://robmensching.com/blog/posts/2009/7/14/Lets-talk-about-Burn

于 2012-04-26T06:03:11.753 回答