nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

How to detect when a feature is being removed by an upgrade?

I have an upgrade where some features are being removed and ultimately replaced with different features. Is there an install condition I can use in the upgrade that will only install the new feature if the old one was present in the previous installation?
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

Hello,

In order to achieve this, you can create a new extended search in the "Search" page. The search should be done by the "Component is installed" condition.

All you need to do is to go to the "Organization" page and take the GUID of a component that is always installed with your feature. Let's consider you have a component such as it follows:

FeatureA:
Components: aa.txt, aa2.txt

In this case, let's consider that aa.txt is not conditioned by anything, therefore it should always install. We can take its' GUID and use it in our search. Basically, the component aa.txt being installed means that the feature is also installed.

You can then use the result of your search to condition your feature. You can go to "Organization" page and select your feature. After doing so, under "Installation Behavior" section, set the default to "Not installed" and the "Installed if:" condition to:

Code: Select all

RESULT_PROPERTY = "1"
Where "RESULT_PROPERTY" is the property that stores the result of your search.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

Re: How to detect when a feature is being removed by an upgrade?

Hi Catalin,

Thank you for the response. I may not completely understand the "Search" feature, but how can I use this to detect that a feature is being removed from an upgrade?

For example, consider this scenario:

1. Version 1.0 may or may not install Feature A.
2. Version 2.0 removes Feature A, and introduces Feature B.
3. An upgrade from Version 1.0 > 2.0 should install Feature B ONLY IF Feature A was present in Version 1.0.

Originally, I tried to do this by making Feature B not installed by default, and

"Installed if:" NOT UPGRADINGPRODUCTCODE OR ((&Feature_A = 2) AND (!Feature_A = 3))

Interpreting this as: If this is an upgrade, only install Feature B if Feature A is being uninstalled.

However, it appears that this does not work. After reading your response, I also tried to do this with a search, using the GUID of the main component from Feature A. This did not seem to work either.

Is there a condition that will detect Feature A being uninstalled because it is no longer present in a new version?
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

Hello,
Thank you for the response.
You are always welcome!
I may not completely understand the "Search" feature, but how can I use this to detect that a feature is being removed from an upgrade?
Please allow me to explain this.

Well, first of all, let's start with what an upgrade means. An upgrade basically means the removal of the older version and the installation of the newer version.

Now, you might questions yourself how the search approach works in an upgrade scenario. What makes this work is the fact that the search is performed before the uninstall of the older version. Just for the sake of this example, we can consider the order as it follows:

Search --> Uninstall of the old product --> Install of the newer product

Basically, the search is performed and, if the component is found, it populates the property assigned to it with the value "1". Let's consider the property that stores the value of the search is named "RESULT_PROPERTY". With that being said, until now, we have the following:

RESULT_PROPERTY = "1"

Now, we will go to the next step. Here, the setup is removed, including your feature.

The next step now is the installation of the newer product. Here, when the moment to install the features come, Windows Installer will verify the condition that you used for your feature and will ask:
Is RESULT_PROPERTY equal to "1"?
It will go and look for the property and will see that it equals to "1". The next step now is to install the feature.

RESULT_PROPERTY = "1" ==> the component exists

the component exists ==> the feature was installed

Hope things are more clear for you now. :)

Also, here is a step-by-step which you can follow to achieve this (first, in a new created project and after you succeed with that, you can modify your main project):

- first of all, create two text files on the disk, e.g.: aa.txt & bb.txt

- open a new Advanced Installer project

- add the aa.txt file in "Files and Folders" page --> under "Application Folder"

- go to "Organization" page and right click on "Product" --> "New Feature". Name the feature, for instance, "FeatureA" and move the "aa.txt" component under the "FeatureA" feature.

- build and install this version of your product. Additionally, make sure the file was correctly installed

- now, in the same project, please add the "bb.txt" file

- in "Organization" page, create a new feature, e.g.: "FeatureB". Move the "bb.txt" component under the "FeatureB" feature

- select the "aa.txt" component and copy its GUID

- now please go to "Search" page. Here, please right click on "Target Computer" --> "New Extended Search" --> "Component is installed". Use the earlier copied GUID in this search.

Additionally, please note the name of the property that stores the result of the search. By default, this is named "RESULT_PROPERTY".

- now please go to "Organization" page and select the "FeatureB" feature. Under "Installation Behavior" field, please set the default to "Not installed" and in the "Installed if" field, please insert the following:

Code: Select all

RESULT_PROPERTY = "1"
- now please go to "Product Details" page and increase the version of your product, e.g.: 1.0.0 --> 1.0.1

- rebuild the project

- in the .AIP, press CTRL + G buttons combination. This will open the folder where the product was built.

- deploy the setup and then check the installation folder again. Now, instead of 1 file (aa.txt), there should be 2 files (aa.txt and bb.txt).

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

Re: How to detect when a feature is being removed by an upgrade?

This helped a lot. I discovered that my problem was using an incorrect condition to detect an upgrade (UPGRADINGPRODUCTCODES instead of OLDPRODUCTS) but when I fixed that, the search worked. Thank you very much for the detailed explanation!
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

Hello,

You are always welcome!

I am really glad everything is working as expected now.

Indeed, those two properties are quite different:

- UPGRADINGPRODUCTCODES is set in the old package

- OLDPRODUCTS is set in the new package

If you have two versions, v1.0 and v2.0, when upgrading the v1.0 using the v2.0, UPGRADINGPRODUCTCODES will be set in v1.0, while OLDPRODUCTS will be set in the v2.0.

For instance, if you have a custom action that you wish to execute during an upgrade (in version v1.0 - for example, when v1.0 is uninstalled by an upgrade), the UPGRADINGPRODUCTCODES condition should be used. Similar to this, if you want to execute a custom (in version v2.0 - for example, when v2.0 is installing), then the OLDPRODUCTS should be used.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

Re: How to detect when a feature is being removed by an upgrade?

Hi Catalin,

I just have one follow-up question about this.

In my previous example, I was dealing with a brand new feature in version 2.0. However, now I would like to install a feature that already existed in version 1.0 but was not installed.

I am using this condition for "Installed if":

Code: Select all

(NOT OLDPRODUCTS) OR (FEATURE_WAS_INSTALLED = "1")
where "FEATURE_WAS_INSTALLED" is the result property of my custom search.

Is there a way to force a feature to be installed in an upgrade even if the feature was NOT installed in the previous version?
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

Hello,

In order to force the installation of a feature, you can go to "Organization" page --> select your feature --> under "Installation Settings" section, please check the "Always install this feature [...]" option.

Also, I believe the default behavior of the feature should be "Installed".

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

Re: How to detect when a feature is being removed by an upgrade?

Hi Catalin,

Sorry for the confusing question. What I really want is not to always install the feature, but only install it if that particular condition is met.

The problem is that, during an upgrade, the installer sees that my feature was not installed in Version 1.0, so it does not install it in Version 2.0, even if the install condition is met.

So I am looking for a way to install a feature in an upgrade even if it was not installed in the previous version.
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

Hello,

Thank you for your followup on this.

I indeed see what you mean now.

Please have a look over the following forum thread:

"Conditional install feature"

in which I have explained why this happens and how to fix it.

Hope this helps.

Best regards,
Catlain
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

Re: How to detect when a feature is being removed by an upgrade?

Hi Catalin,

Is there any way to do this for one particular feature?

I do not want to lose the information about the other features which have been installed. If not, I suppose a workaround could be to rename the feature in version 2.0 so that it installs anyway.
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

Hello,

Yes, this can be achieved for a particular feature.

First of all, the MigrateFeatureState action takes place right before the dialogs are spawned.

With that in mind, we can have an event on our "WelcomeDlg" that will install our feature based on a condition.

To do so, you can go to "Dialogs" page --> select "WelcomeDlg" --> select the "Next" button and, under "Published Events", add a new event as it follows:

Event: Install one or more features locally
Argument: your_feature_identifier (there is a dropdown there from which you can select your feature)
Condition: your_condition


This way, the feature state will be basically overwritten and the feature should be installed (if the condition is evaluated as true).

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nghobrial
Posts: 10
Joined: Thu Mar 14, 2019 3:05 pm

Re: How to detect when a feature is being removed by an upgrade?

Thanks a lot Catalin. This was all very helpful. Thank you for all your help.
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect when a feature is being removed by an upgrade?

You are always welcome!

I am really glad the information was helpful and that everything works as expected now.

It is always my pleasure to help.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”