jbudreau
jbudreau

Reputation: 1307

Why is MsiGetFeatureState() returning INSTALLSTATE_ADVERTISED for my un-advertisible feature?

I've got an MSI built in WiX defined as below:

<Feature Id="Core"
         Display="0"
         Absent="disallow"
         ConfigurableDirectory="INSTALLDIR"
         AllowAdvertise="no"
         Level="1">...</Feature>

I have a 'commit' custom action that loops through all the features of the MSI and determines their install-state. The log file shows this "Core" feature as installed 'Local', but MsiGetFeatureState returns INSTALLSTATE_ADVERTISED. I thought that was impossible given I set:

AllowAdvertise="no"

FWIW, MsiGetFeatureState correctly returns INSTALLSTATE_LOCAL for all other installed features and INSTALLSTATE_ABSENT for all other not-installed features.

Edit for more info:

Upvotes: 0

Views: 561

Answers (2)

jbudreau
jbudreau

Reputation: 1307

Found out what the problem was (I think).

I had a custom action that would call MsiSetComponentState() to set a component to INSTALLSTATE_ABSENT if some condition was true. This means that my 'Core' feature was intended to have every attached component set to INSTALLSTATE_LOCAL, but since this one component was manually forced into INSTALLSTATE_ABSENT the 'Core' feature (once installed) is considered to have an install state of 'Advertised'. An additional consequence was that during uninstall all components attached to the 'Core' feature were getting left behind. Their action states were NULL (do nothing) instead of Absent (remove).

Moral of the story, don't use MsiSetComponentState() to turn off a component at install time.

Upvotes: 0

Bob Arnson
Bob Arnson

Reputation: 21886

AllowAdvertise="no" turns into msidbFeatureAttributesDisallowAdvertise in the Feature table, which says:

Note that this bit works only with features that are listed by the ADVERTISE Property.

IOW, if it became advertised for some other reason, this bit won't stop that.

Upvotes: 1

Related Questions