【问题标题】:Can't get Wix custom action to work in Votive/VS2010无法让 Wix 自定义操作在 Votive/VS2010 中工作
【发布时间】:2011-04-29 19:02:30
【问题描述】:

帮助!我需要在我的 Wix 3.5 设置项目中执行托管自定义操作,但无论我尝试了什么,我都无法让它工作。

我在 Visual Studio 2010 中使用 Votive 集成。我的 Wix Product.wxs 文件与 Visual Studio 模板基本相同,除了一些文本更改:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="666ffc07-90b2-4608-a9f0-a0cc879f2ad0" Name="Product Name" Language="1033" Version="5.5.0002" Manufacturer="TiGra Astronomy" UpgradeCode="d17a5991-b404-4095-9e93-08d2db984cfd">
    <Package InstallerVersion="200" Compressed="yes" />

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="Directory Name">
                <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
                <!-- <Component Id="ProductComponent" Guid="3ea5ade7-9b7b-40da-9e83-13e066a000ef"> -->
                    <!-- TODO: Insert files, registry keys, and other resources here. -->
                <!-- </Component> -->
            </Directory>
        </Directory>
    </Directory>

    <Feature Id="ProductFeature" Title="ASCOM Driver" Level="1">
        <!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
        <!-- <ComponentRef Id="ProductComponent" /> -->

        <!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->
        <ComponentGroupRef Id="Product.Generated" />
    </Feature>
</Product>

我已设置对我的托管自定义操作项目的引用,将 HARVEST 属性设置为 true。该项目名为WIX.CustomActions 并生成WIX.CustomActions.dllWIX.CustomActions.CA.dll

我看到 Wix 在构建期间正在处理引用,WIX.CustomActions.dll 程序集显示在最终设置项目的二进制表中,但 WIX.CustomActions.CA.dll 没有。

我有一个 CustomActions.wxs 应该打包并调用自定义操作:

    <?xml version="1.0" encoding="UTF-8" ?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <Binary Id="DriverRegistrationCA" SourceFile="$(var.WIX.CustomActions.TargetDir)\$(var.WIX.CustomActions.TargetName).CA.dll" />
    <CustomAction Id="RegisterDriver" BinaryKey="DriverRegistrationCA" DllEntry="RegisterAscomDriver" Execute="deferred" Return="check" />
    <CustomAction Id="UnregisterDriver" BinaryKey="DriverRegistrationCA" DllEntry="UnregisterAscomDriver" Execute="immediate" Return="check" />
    <InstallExecuteSequence>
      <Custom Action="RegisterDriver" After="InstallFinalize" />
      <Custom Action="UnregisterDriver" Before="RemoveFiles" />
    </InstallExecuteSequence>
  </Fragment>
</Wix>

我查看了互联网上的各种“howto”资源,它们充其量只是令人困惑,而且建议相互矛盾。据我了解,WIX.CustomActions.CA.dll 文件是一个非托管 dll,它加载 .NET 框架并将控制权传递给“真正的”托管自定义操作。但是,WIX.CustomActions.CA.dll 没有打包在我的 MSI 文件中。我已尽我所能地遵循示例,但我看不出有什么问题。

请问,有没有人在 Votive 中进行过这项工作?你能给我一个实际的工作例子吗?

【问题讨论】:

    标签: visual-studio wix windows-installer custom-action votive


    【解决方案1】:

    您需要从产品到片段的引用(例如 CustomActionRef);否则,它会被智能链接器丢弃。

    【讨论】:

    • Votive 不是通过&lt;ComponentGroupRef Id="Product.Generated" /&gt; 行来实现的吗?如果没有,你能举个具体的例子吗?
    • 绝对是个好建议。我在我的 Product.wxs 顶部附近添加了几个 CustomActionRef 行,现在 CA 出现在 MSI 文件中。Bob,你是一个超级明星。为什么哦,为什么没有一个例子提到那一步?
    【解决方案2】:

    根据 Bob Arnson 的建议,我在 Product.wxs 文件的顶部附近添加了以下两行:

    <CustomActionRef Id="RegisterDriver"/>
    <CustomActionRef Id="UnregisterDriver"/>
    

    这似乎成功了。 Orca 现在显示我有一个二进制表,其中包含我的 CA dll,以及 InstallExecuteSequence 中的 CustomAction 条目。

    我在网上找到的例子都没有提到这个要求。我猜人们只是在很少或根本不了解的情况下回收收到的智慧。所以这就是答案,感谢 Bob!

    【讨论】:

    • 只有当您想要的创作在不同的片段中时,您才需要参考。你只需要一个——链接器会在找到一个引用时拉入整个片段。这是递归的,所以如果在该片段中创作具有对不同片段中的 id 的引用,则该片段也会被拉入。 (例如,CustomAction/@BinaryKey 是对 Binary/@Id 的引用。)
    猜你喜欢
    • 2011-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多