wix - 如何使用 WIX 安装两个 MSI 包和一个 MSI 包?

标签 wix windows-installer chain runner

我有一个场景,要安装两个 MSI 包和一个 MSI 包。

例如,我们有两个产品要安装,即。 Sample1.MSI 和 Sample2.MSI。 我们需要将 Sample2.MSI 包嵌入到 Sample1.MSI 中。 如果我们安装 Sample1.MSI,它应该同时安装 Sample1.MSI 和 Sample2.MSI,这应该在添加或删除程序 (appwiz.cpl) 中创建两个条目。

搜索后,我找到了一个示例应用程序,它使用“EmbeddedChainer”标签,安装后可以正常工作。但它没有正确卸载。

    <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代码

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;
    }
}

这哪里搞砸了?

请问除了这种方法还有什么更好的方法吗?

最佳答案

您可以使用 Wix Burn 创建包含多个应用程序安装程序的安装包:

关于wix - 如何使用 WIX 安装两个 MSI 包和一个 MSI 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15803452/

相关文章:

Wix 工具集 : complete cleanup after "disallowing uninstallation of component since another client exists"

permissions - Wix:如何设置文件夹和所有子文件夹的权限

wix - 在WiX中静默安装根证书

windows - Windows Installer服务启动时/V键是什么意思?

wix - 如何让 WiX 生成 64 位 MSI?

r - 使用 dplyr 进行管道传输时获取 lhs 对象名称

javascript - 在 JavaScript 的 block 作用域内使用 'var' 声明的内部函数表达式

visual-studio - Wix MajorUpgrade 不会检测产品版本的最后位置

windows-installer - 用于了解 Windows Installer 的推荐资源

Java 8 结果链接