【问题标题】:WiX: Passing Data to managed custom action does not workWiX:将数据传递给托管自定义操作不起作用
【发布时间】:2010-10-12 19:19:40
【问题描述】:

我遇到了关于 wix 和托管自定义操作的问题:我已经管理它以创建托管自定义操作并从我的安装程序中调用它(在安装日志文件中验证它)。我现在的问题是我没有设法将数据传递给自定义操作。 Afaik 如果我选择在这么晚的阶段运行自定义操作,我必须将该操作标记为“延迟”。有了这个限制,就只能访问 CustomActionData 属性吗?为什么这在我的情况下不起作用? (据我所见,我从样本中正确采用了一切?)

这是我已经尝试过的:

自定义操作:

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

        session.Log("Before Access to customactiondata");
       //string helpdir = session["HELP_DIR"];
        string cad = session["CustomActionData"];
        Debugger.Break();
        session.Log("Help dir is: " + helpdir);
        session.Log("Custom Action Data is: " + cad);
        return ActionResult.Success;
       }

}

调用自定义操作的合并模块:

<CustomAction Id='RegisterDflHelp' BinaryKey='RegisterDflHelpDll' DllEntry='RegisterDflHelp' Execute='deferred' />

<CustomAction Id="HELP_DIR.SetProperty" Return="check" Property="HELP_DIR" Value="Teeest" />

<Property Id='HELP_DIR' Secure='yes'/>

<InstallExecuteSequence>
  <Custom Action='HELP_DIR.SetProperty' After='InstallFiles' />
  <Custom Action='RegisterDflHelp' After='HELP_DIR.SetProperty' />
</InstallExecuteSequence>

<Directory Id="TARGETDIR" Name="SourceDir">
    </Directory>
<ComponentGroupRef Id="HelpGroup"/>

包含帮助合并模块的产品:

<Product....>
<Package....>
...
<Directory>
<!--Directory which gets the help folder--!>
<Merge Id ="DflHelpInstaller" SourceFile="DflHelpInstaller.msm" Language="1033" DiskId="1" />

任何人的想法?提前致谢!!

丹尼尔

顺便说一句:还有什么有趣的事情要知道:在安装过程的哪个阶段必须将操作标记为延迟?如果我设法在这个阶段之前调用我的自定义操作。有什么好处?

【问题讨论】:

    标签: wix windows-installer wix3


    【解决方案1】:

    您仍在设置HELP_DIR 属性而不是自定义操作数据。如果您尝试将 RegisterDfHelp 操作的 CustomActionData 设置为“Teeest”,那么我认为您应该这样做:

    <CustomAction Id="SetRegisterDflHelpCustomActionData" Return="check" 
       Property="RegisterDflHelp" Value="Teeest" />
    
    <InstallExecuteSequence>
       <Custom Action='SetRegisterDflHelpCustomActionData' After='InstallFiles' />
       <Custom Action='RegisterDflHelp' After='SetRegisterDflHelpCustomActionData' />
    </InstallExecuteSequence>
    

    【讨论】:

      【解决方案2】:

      有时候动动脑子真的很有帮助;-)

      上面的示例不起作用的原因很简单:

      代替:

      CustomAction Id="HELP_DIR.SetProperty" Return="check" Property="HELP_DIR" Value="Teeest" />
      

      我开始将属性属性设置为应该获取自定义数据的操作!!这里:

      <CustomAction Id="HELP_DIR.SetProperty" Return="check" Property="RegisterDflHelp" Value="$(var.HelpSourceDir)" />
      

      希望能帮助其他人节省我花在解决这个愚蠢问题上的时间;-)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多