cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
snatarajan
Level 2

Conditional copy of merge modules not working

Hi,

I have created a property that will get set with a value read from an XML file during installation. I have a custom action that reads the XML file and updates the property and all this works fine. I am trying to restrict or allow certain components/Features to be copied based on the value held in the property and this does not seem to work. I have added a condition like "property = value" to the Features but they are getting copied always. How can i check if the value of the property is what i expect it to be during the copy? I have validated the value is indeed updated by calling MsiGetProperty on the property after the MsiSetProperty. Any help is appreciated as this is urgent. thanks.
Labels (1)
0 Kudos
(3) Replies
DLee65
Level 13

Are you setting conditions on the feature or the components within a feature?

Conditions on a feature behave a little different than conditions on a component. Where conditions on a component simply evaluate to true or false, conditions on a feature evaluate to true or false and then set an install level for that particular component. Depending on what your InstallLevel property is set to, the feature and its components will install or not install.

In my installer I have features sets for a client install, and feature sets for a server install.
For each Feature, I set the install Level value to Zero (0), this means that the feature is hidden and will not be installed.
For each feature, I set a condition. For the client install I set a condition of NOT SERVERCOMPUTER ~= "YES", for the server install I set a condition of SERVERCOMPUTER ~="YES". I set the Level value for each condition to '3'. This ensures that the feature will install if the condition is met.
Another thing to note is that you must set your property before CostFinalize because feature state is evaluated to determine the install cost. I think the only time this isn't true is if the Install Level property has been changed.

If you are still having problems, look at the MSI install log and check the Install Level property to see if it set to the value you expect.
0 Kudos
snatarajan
Level 2

Thanks DLee65.

Just to clarify all the points that you have touched upon.

I had the condition put for both the feature and the component as i was not sure which is the right place. I have changed it to the Feature after your recommendation and have set the level to 1.

The value that i read from the config file can be one of two values say, ONE and TWO. If (property=ONE) install some features, If(property=TWO), install some other features is what i am looking for.

The INSTALLLEVEL property in the log is set to 100.
I had initially not associated any component to the features, but now i have done that. Now i see that nothing is getting installed in the Program Files directory, it is probably because the condition are not evaluated correctly...

why have you used ~= in your example? Is that same as == in C#?

I am setting the property before the CostFinalize and so i am good there.

How can i figure out if the condition that i am including is actually being evaluated?
And how can i know what is the value of the property that i am using in the condition when the condition is being executed?
0 Kudos
Not applicable

I know this is an old thread but it was never answered.

From what I've read you are setting the InstallLevel of the feature to 1 based off of a condition. However, to NOT install or show a feature - the install level needs to be set to 0.

Clicking on the Conditions for a Feature you would add:
Feature A
Level = 0, Condition = "property = ZERO"
Level = 1, Condition = "property = ONE"

Feature B
Level = 0, Condition = "property = ZERO"
Level = 1, Condition = "property = ONE or property = TWO"

etc..
0 Kudos