开发者

Custom action is not running

I've got a custom action I've defined for my installer. The installer doesn't seem t开发者_运维技巧o be running.

Here's the lines in the WXS file that define the custom action:

    <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" />

I've checked the MSI with Orca and the appropriate entries are in the MSI's tables.

Here's an excerpt of the code in the CustomActions.cs file:

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

        . . .


        return ActionResult.Success;
    }

There are a few other session.Log statements in the code at places where I wanted to see what was going on.

Now, I have logging enabled. When I look at the log file in Notepad, I see no messages from my calls to session.Log. I see no references to GetConfigProperties either. It appears that the custom action is not executing at all. What have I done wrong?


It turns out that the custom action wasn't running because:

  1. It was scheduled to run in the wrong place. My fault, I needed to put it in the InstallUISequence section, not the InstallSequence section.

  2. I was aborting the install before the action could run.

When I put the custom action into the InstallUISequence section and in the right place, everything ran fine.

Thanks for trying.

Tony


In case you don't see any entries of GetConfigProperties custom action in your log file, most likely the reason is that InstallExecutesequence element resides in a separate Fragment, which is not included into the package. To include the contents of the Fragment into the package, you should reference any element in it from inside the Product element.

For instance, you can add the following line to the Product element:

<CustomActionRef Id="GetConfigProperties" />


I think you are missing condition on which custom action should run. Either give some condition <Custom Action="GetConfigProperties" After="FindRelatedProducts">NOT INSTALLED AND NOT REMOVE</Custom> or if you want to make it default then put 1 as condition <Custom Action="GetConfigProperties" After="FindRelatedProducts">1</Custom>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜