1

帮助!我需要在我的 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 有这个工作?你能给我一个实际的工作例子吗?

4

2 回答 2

4

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

于 2011-04-29T19:49:54.740 回答
1

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

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

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

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

于 2011-04-29T20:58:53.690 回答