Using a Feature To Run a CustomAction at the Proper Time - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

invalidptr
Posts: 79
Joined: Thu Nov 18, 2010 7:10 pm

Using a Feature To Run a CustomAction at the Proper Time

I had just fixed a problem and realized there might be a better way.

What I did to get my Windows Service installed:
- Based on user selection I either installed FeatureA or FeatureB and made a note of the selection in a global property.
- During the InstallExecuteSequence under InstallServices I was executing a CustomActionProperty based on whether FeatureA or FeatureB was installed (by checking the global property)
- The problem was update was failing because the user couldn't select FeatureA or FeatureB and my global property was "lost". So to fix that problem i wrote it to the registry and the loaded it during an update.

- But then I realized I could probably better do this by using !MyFeature=3 (INSTALLSTATE_LOCAL) for my Execution Condition.

The problem is, this didn't work. Looking at the logs my guess is that maybe at the time my Action is run in the update condition, the feature isn't technically installed. Bummer.

Am I thinking about this problem right? Is there some place else I should be doing this? It turns out my CustomAction is a WixCA so technically doesn't need to have the product installed. If I put it in the Commit stage my system rebooted which is not desirable.

So, is there a way I can leverage the Feature tag to perform a CustomAction based on said Feature condition without introducing a reboot to my update?

Thanks
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Using a Feature To Run a CustomAction at the Proper Time

Hi

In the "Condition" field from your custom action, use [...] button in order to add a control condition. The "Edit Condition" dialog will appear.
From "Predefined Conditions" group select "Test if the feature will be installed local. The feature is not reinstalled." condition and click [Insert] button or double click it in the list to add it. From "Select a feature" dialog select the desired feature and click [OK] button.

I hope this will help you.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
invalidptr
Posts: 79
Joined: Thu Nov 18, 2010 7:10 pm

Re: Using a Feature To Run a CustomAction at the Proper Time

I didn't get a chance to test this today but here is the Expression I was using

Code: Select all

(Not Installed) and (UILevel <> 2) and !MyFeature=3
When I selected "Test if the feature will be installed local. The feature is not reinstalled." as you suggested I got:

Code: Select all

((&MyFeature = 3) AND NOT (!MyFeature = 3))
My codes says "Feature State is Local"
The new code says "Feature Action is Local and Feature State is NOT Local". And I reading that right?

Does this work because at the time this is executed the Feature State has been uninstalled and now we're in the reinstall phase so the Feature Action is to make it Local (to install it).

Return to “Common Problems”