For those who are searching for an answer, this is what has worked for us:

private void PlanPackageBegin(object sender, PlanPackageBeginEventArgs e)

    // if this is the package, which has optional features
    if (e.PackageId.Equals("<package_ID_with_optfeatures>",
StringComparison.Ordinal))
    {
       // if the action being planned is Modify
       if (this.plannedAction == LaunchAction.Modify)
       {
           // set the state of the package to present, which will prompt the
call to PlanMsiFeatures
           e.State = RequestState.Present;
       }
    }

and as you can see in the log, it correctly finds that I have 3 features
installed and that I want to remove two of them (and does so quite nicely! 
):

[1078:0A18][2012-10-09T07:55:06]: Condition 'NOT ((VersionNT = 600 AND
ServicePackLevel >=2) OR (VersionNT >= 601))' evaluates to true.
[1078:0A18][2012-10-09T07:55:06]: Loading managed bootstrapper application.
[1078:0A18][2012-10-09T07:55:06]: Creating BA thread to run asynchronously.
[1078:1160][2012-10-09T07:55:06]: Running the WiX BA
[1078:0A18][2012-10-09T07:55:06]: Detect 2 packages
[1078:1160][2012-10-09T07:55:06]: Setting string variable 'InstallPath' to
value 'C:\Program Files (x86)\Hippo'
[1078:1160][2012-10-09T07:55:06]: Creating a UI.
[1078:0A18][2012-10-09T07:55:06]: Detected package: Hippo, state: Present,
cached: Complete
[1078:0A18][2012-10-09T07:55:06]: Detected package: Hippo, feature:
PIDService, state: Absent
[1078:0A18][2012-10-09T07:55:06]: *Detected package: Hippo, feature: Server,
state: Local*
[1078:0A18][2012-10-09T07:55:06]: *Detected package: Hippo, feature:
Bulkload, state: Local*
[1078:0A18][2012-10-09T07:55:06]: *Detected package: Hippo, feature:
ProjectEnvironment, state: Local*
[1078:0A18][2012-10-09T07:55:06]: Detected package: Hippo, feature:
IFCService, state: Absent
[1078:0A18][2012-10-09T07:55:06]: Detected package: Hippo_Server, state:
Present, cached: Complete
[1078:0A18][2012-10-09T07:55:06]: Detect complete, result: 0x0
[1078:0A18][2012-10-09T08:42:35]: Plan 2 packages, action: Modify
[1078:0A18][2012-10-09T08:42:43]: Plan 5 msi features for package: Hippo
[1078:0A18][2012-10-09T08:42:43]: Planned feature: PIDService, state:
Absent, default requested: Unknown, ba requested: Absent, execute action:
None, rollback action: None
*[1078:0A18][2012-10-09T08:42:43]: Planned feature: Server, state: Local,
default requested: Unknown, ba requested: Local, execute action: None,
rollback action: None*
[1078:0A18][2012-10-09T08:42:43]: *Planned feature: Bulkload, state: Local,
default requested: Unknown, ba requested: Absent, execute action: Remove,
rollback action: AddLocal*
[1078:0A18][2012-10-09T08:42:43]: *Planned feature: ProjectEnvironment,
state: Local, default requested: Unknown, ba requested: Absent, execute
action: Remove, rollback action: AddLocal*
[1078:0A18][2012-10-09T08:42:43]: Planned feature: IFCService, state:
Absent, default requested: Unknown, ba requested: Absent, execute action:
None, rollback action: None
[1078:0A18][2012-10-09T08:42:43]: Setting string variable
'WixBundleRollbackLog_Hippo' to value
'C:\Users\sp3dtest\AppData\Local\Temp\COMPANY_NAME_20121009075506_0_Hippo_rollback.log'
[1078:0A18][2012-10-09T08:42:43]: Setting string variable
'WixBundleLog_Hippo' to value
'C:\Users\sp3dtest\AppData\Local\Temp\COMPANY_NAME_20121009075506_0_Hippo.log'
[1078:0A18][2012-10-09T08:42:43]: Planned package: Hippo, state: Present,
default requested: None, ba requested: Present, execute: Modify, rollback:
Modify, cache: No, uncache: No, dependency: Register
[1078:0A18][2012-10-09T08:42:43]: Planned package: Hippo_Server, state:
Present, default requested: None, ba requested: None, execute: None,
rollback: None, cache: No, uncache: No, dependency: None
[1078:0A18][2012-10-09T08:42:43]: Plan complete, result: 0x0
[1078:0A18][2012-10-09T08:42:43]: Apply begin

Many thanks for the help!

Brian



--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Detecting-Feature-state-in-Managed-BA-tp7580920p7581244.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to