是否可以从设置库中导入WiX自定义操作,或者有另一种方法可以实现相同的功能? [英] Can WiX custom actions be imported from a setup library or is there another method to achieve the same functionality?

查看:89
本文介绍了是否可以从设置库中导入WiX自定义操作,或者有另一种方法可以实现相同的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由4个不同的安装程序库组成的程序。我想做的是完全分隔这些库,以便我可以轻松地重用它们或根据安装的内容限制程序的功能。目前,我所有的自定义操作都在安装程序内部声明。我希望这些自定义操作驻留在它们各自的安装程序库中,并在installexecutesequence中指定它们。 WiX可以做到这一点吗?到目前为止,这是我一直没有用的。

I have a program that is composed of 4 different setup libraries. What I would like to do is completely compartmentalize these libraries so that I can easily reuse them or limit the functionality of the program based on what gets installed. Currently, all of my custom actions are declared inside the installer itself. I would like to have these custom actions reside in their respective setup libraries as well as specify them in the installexecutesequence. Is this something that is possible with WiX? So far, this is what I have tried to no avail.

项目A SetupLibrary

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
    <?if $(var.Platform) = x86?>*See note
        <CustomAction Id="MyCustomAction" FileKey="Somefile.exe" Execute="deferred" ExeCommand="CmdLineArgs" Return="check"/>
        <InstallExecuteSequence>
            <Custom Action="MyCustomAction" After="StartServices"/>
        </InstallExecuteSequence>
    <?endif ?>
    </Fragment>
</Wix>

* 我有这种情况可以防止自定义操作在我的主项目中生成两次我同时导入了此安装程序库的32位和64位版本。

使用上述方法,我的项目可以很好地编译,但是自定义操作无处可用编译后可在MSI的自定义操作表中找到。如果我在安装程序的InstallExecuteSequence中明确列出了自定义操作,则该操作有效,但是这违反了我的最终目标,即将所有这些组件包装在自己的安装库中。

Using this above method, my project compiles just fine, but the custom action is nowhere to be found in the Custom Actions table of the MSI upon compilation. If I explicitly list the custom action inside the InstallExecuteSequence inside my installer, it works, however that defeats my end goal of having all these components wrapped up in their own setup libraries.

推荐答案

不,您总是必须在 Product 元素可从其他任何地方插入声明,甚至在同一文件中也包括 Fragment 。在这种情况下,创作将是 InstallExecuteSequence / Custom / @ Action 引用。

No, you always have to add some sort of authoring under the Product element to pull in declarations from anywhere else, including a Fragment even in the same file. In this case the authoring would be the InstallExecuteSequence/Custom/@Action reference.

至少有三种方法可以避免将该元素的文本直接放入设置项目代码中:

There are at least three ways to avoid putting the text of that element directly into your setup project code:


  1. 预处理器<?include ../ProjectA/libraryA.wxi?> ,这将需要绝对或相对路径

  2. 在扩展中实现的自定义元素

  3. 合并模块引用

  1. a preprocessor <?include ../ProjectA/libraryA.wxi ?>, which would necessitate an absolute or relative path
  2. a custom element, implemented in an extension
  3. a merge module reference

扩展似乎太过分了。如果可以的话,我会使用包含。

An extension seems like overkill. I'd use an include if I could.

这篇关于是否可以从设置库中导入WiX自定义操作,或者有另一种方法可以实现相同的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆