2011-09-13 145 views
2

我有一个custom action我已为我的安装程序定义。安装程序似乎没有运行。自定义操作未运行

这里是在WXS文件中定义的自定义动作的台词:

<CustomAction Id="GetConfigProperties" BinaryKey="GetPropertiesDLL" DllEntry="GetPropertiesFromConfigFile" /> 

    <InstallExecuteSequence> 
     <RemoveExistingProducts After="InstallInitialize" /> 
     <Custom Action="NewerVersionDetected" After="FindRelatedProducts">NEWERVERSIONDETECTED</Custom> 
     <Custom Action="GetConfigProperties" After="FindRelatedProducts"></Custom> 
     . . .    
    </InstallExecuteSequence> 

    <Binary Id="GetPropertiesDLL" SourceFile="$(var.LPRCore Installer CBP Helper.TargetDir)\LPRCore Installer CBP Helper.CA.dll" /> 

我检查与海怪的MSI和相应的条目是在MSI的表。

下面的代码的摘录中CustomActions.cs文件:

[CustomAction] 
    public static ActionResult GetPropertiesFromConfigFile(Session session) { 
     // Output a start message to the install log 
     session.Log("Begin GetPropertiesFromConfigFile"); 

     . . . 


     return ActionResult.Success; 
    } 

有在哪里我想看看发生了什么事情的地方代码的一些其他session.Log声明。

现在,我已启用日志记录。当我在记事本中查看日志文件时,我看不到来自session.Log的呼叫消息。我也没有看到GetConfigProperties的提及。看起来,自定义操作根本没有执行。我做错了什么?

回答

5

事实证明,自定义操作不运行,因为:

  1. 它被安排运行在错误的地方。我的错,我需要把它放在InstallUISequence部分,而不是InstallSequence部分。

  2. 我在操作运行之前中止了安装。

当我把自定义动作放到InstallUISequence部分,并在正确的地方,一切运行良好。

感谢您的尝试。

Tony

-1

我认为你缺少自定义操作应该运行的条件。要么给一些条件<Custom Action="GetConfigProperties" After="FindRelatedProducts">NOT INSTALLED AND NOT REMOVE</Custom>或者,如果你想让它默认然后把1作为条件 <Custom Action="GetConfigProperties" After="FindRelatedProducts">1</Custom>

+2

不,这是不正确的。如果您省略该条件,则默认为1 –

2

如果你没有看到你的日志文件GetConfigProperties自定义操作中的任何条目,最有可能的原因是,InstallExecutesequence元素位于单独的片段中,该片段未包含在软件包中。要将Fragment的内容包含到包中,您应该从Product元素中引用其中的任何元素。

例如,您可以将下面的行添加到产品元素:

<CustomActionRef Id="GetConfigProperties" />