Dev
Posts: 17
Joined: Mon Oct 06, 2008 6:55 am

Conditional Features

I'm having trouble with getting Features (and/or components - I'm not really sure of the difference) to install based on conditions set from a dialog. I've read through the forums, and tried a number of different ways to do this.

I'm trying to create an installation where the user is presented with 3 choices - website only install, server agent install, or standalone install. I simply made a few changes to the built-in SetupTypeDlg, changing the text as needed for the three buttons. The (formerly) Typical button has a published event for:
Event: FEATURE_WEB = 1
Argument: 1
Condition: AI_INSTALL (I couldn't get this to change)

The second button (formerly Custom Install) now has NewDialog set to VerifyReadyDlg, and sets [FEATURE_AGENT] in the same way as above.
I then tried this a couple ways without success. First, I set the 'Website' feature (in Organization tab) to install the feature if INSTALLLEVEL > 999, with a Conditional Install Level set to:
Condition: FEATURE_AGENT = 1
Level: 1000

This did not work. Next, after reading about issues using properties set from the UI that aren't read until after CostFinalize, I tried adding a custom action with VBScript. I tried it both with the action listed under Install and CostInitilize (which I presume is before CostFinalize). The VBScript is (with some MsgBoxes for debugging):

Code: Select all

Function SetInstallFeatures()
	MsgBox "Script Version: 4"
	Dim Feature_Web
	Dim Feature_Agent
	Feature_Web = Session.Property("FEATURE_WEB")
	Feature_Agent = Session.Property("FEATURE_AGENT")


	MsgBox "FEATURE_WEB: " & Feature_Web
	MsgBox "FEATURE_AGENT: " & Feature_Agent
	if Feature_Agent = 1 Then
		msgBox "Installing Agent"
		Session.FeatureRequestState("Agent") = 3	'Will be installed
		Session.FeatureRequestState("Website") = 2	'Will not be installed
		msgBox "Finished installing Agent"
	Else
		MsgBox "Installing Web"
		Session.FeatureRequestState("Website") = 3	'Will be installed
		Session.FeatureRequestState("Agent") = 2	'Will not be installed
		msgBox "Finished installing Web"
	End If
	MsgBox "Done"
End Function
Accoding to the last MsgBox I see, it seems to fail at the line that says:
Session.FeatureRequestState("Agent") = 3 'Will be installed

I even tried simply making the Conditional Level for the Feature to:
Condition: 1 = 1
Level: 1000
...and that didn't work either.


So...what am I doing wrong? What is the best way to do a conditional install based on user selection (I don't want to do the standard Typical/Custom/Complete with custom selections that way).
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Conditional Features

Hi,
I'm having trouble with getting Features (and/or components - I'm not really sure of the difference) to install based on conditions set from a dialog.
Please note that you can read more about features and components here:
Windows Installer Features
Windows Installer Components

Also, note that the User Guide contains the Show a custom feature selection dialog how-to which may help you.
I simply made a few changes to the built-in SetupTypeDlg, changing the text as needed for the three buttons.
Please note that these buttons control the installation level, not the features. The installation level determines automatically which features will be installed. For your case, you can try creating a custom dialog which uses the three buttons, but does not set the installation level. These buttons can set properties which can be used to configure the features in the package (like in the how-to I mentioned). Please note that all buttons should use "NewDialog" control events which show the next dialog.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dev
Posts: 17
Joined: Mon Oct 06, 2008 6:55 am

Re: Conditional Features

cosmin wrote:Hi,
I simply made a few changes to the built-in SetupTypeDlg, changing the text as needed for the three buttons.
Please note that these buttons control the installation level, not the features. The installation level determines automatically which features will be installed. For your case, you can try creating a custom dialog which uses the three buttons, but does not set the installation level. These buttons can set properties which can be used to configure the features in the package (like in the how-to I mentioned). Please note that all buttons should use "NewDialog" control events which show the next dialog.

Regards,
Cosmin
So are you saying that the reason that the Conditional Install Level is not working is because the INSTALLLEVEL has already been set from the SetupTypeDlg and I'm not able to override it from the Conditional Install Level dialog?
Dev
Posts: 17
Joined: Mon Oct 06, 2008 6:55 am

Re: Conditional Features

Nevermind - the http://www.advancedinstaller.com/user-g ... ature.html page completely answered my question. Sorry, hadn't come across that exact sample before.

Return to “Common Problems”