简体   繁体   English

无法将我的WiX自定义操作安排到MSI中

[英]Unable to schedule my WiX Custom Action into the msi

I have an installer solution in visual studio that contains the C# windows application bootstrapper, and two msi projects. 我在Visual Studio中有一个安装程序解决方案,其中包含C#Windows应用程序引导程序和两个msi项目。 I want to schedule a custom action for one of two msis to run during the uninstall sequence - so I first added a CustomActions projects to the same solution (called "CustomActions"), which has the CustomAction.cs file that defines the custom function to be scheduled. 我想为在卸载序列中运行的两个msis中的一个安排自定义操作-因此,我首先向同一个解决方案(称为“ CustomActions”)中添加了一个CustomActions项目,该项目具有CustomAction.cs文件,该文件将自定义函数定义为被安排。 This function should just write something to the log file for now: 此函数现在应该只向日志文件中写入一些内容:

namespace CustomActions
{
    public class CustomActions
    {
        [CustomAction]
        public static ActionResult UninstallSecondaryMsi(Session session)
        {
            session.Log("Begin CustomAction1");

        /* Search for ProductCode of the secondary msi here; run msiexec to uninstall it */

            return ActionResult.Success;
        }
    }

I added the CustomActions project reference to my msi project, and then added the following to my product.wxs: 我将CustomActions项目引用添加到我的msi项目中,然后将以下内容添加到我的product.wxs中:

    <!-- Custom Actions -->
    <Fragment>
      <Binary Id="customActionDLL" SourceFile="$(var.CustomActions.TargetDir)\CustomActions.CA.dll" />
      <CustomAction Id="CustomAction_GetRegistryKey"
        BinaryKey="customActionDLL"
        DllEntry="UninstallSecondaryMsi"
        Execute="immediate"
        Return="check" />

    <InstallExecuteSequence>
      <Custom Action="CustomAction_GetRegistryKey"
              After="InstallFinalize"></Custom>
    </InstallExecuteSequence>
  </Fragment>

I ran the bootstrapper that triggers the msi, but the "Begin CustomAction1" string was not in the log file. 我运行了触发msi的引导程序,但是日志文件中没有“ Begin CustomAction1”字符串。 I thought maybe it wasn't just logging properly, but when I viewed the generated msi with Orca.exe, I saw that my custom action was not scheduled under the CustomActions table or the InstallExecuteSequence table. 我以为可能不仅记录正确,而且当我使用Orca.exe查看生成的msi时,我发现自定义操作计划在CustomActions表或InstallExecuteSequence表下进行。

Is there something that I'm missing here? 我在这里缺少什么吗? I also guessed that the path to the CustomActions.CA.dll wasn't correct and tried hard-coding the path to the DLL, but that did not work either. 我还猜测到CustomActions.CA.dll的路径不正确,并尝试对DLL的路径进行硬编码,但这也不起作用。 Any help would be greatly appreciated, thanks in advance! 任何帮助将不胜感激,在此先感谢!

Ah, my Custom Actions elements were in the main Product.wxs file but in a different fragment, and that fragment wasn't getting referred to anywhere. 嗯,我的Custom Actions元素在Product.wxs主文件中,但是在另一个片段中,并且该片段在任何地方都没有被引用。 I put in a ComponentGroup under that Fragment and made a reference to its ID under the Feature element - and it worked. 我在该片段下放置了一个ComponentGroup,并在Feature元素下对其ID进行了引用-并且它起作用了。 My apologies. 我很抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM