We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Feature Install States and ADDLOCAL

Hello!

My Problem:
I have a deferred custom action that runs code based on the install state of a feature. For example:

Code: Select all

If (FeatureA is installed)
   Run this code
elseif (FeatureA is installed AND FeatureB is NOT installed)
   Run this code
etc.
Since deferred custom actions can't access the install state of a feature directly (ex: session["FeatureA"].RequestState), I have to obtain the install state a different way. So, I decided to pass in the "ADDLOCAL" property into CustomActionData. The problem is, it appears "ADDLOCAL" is not being set during a silent install (but "ADDLOCAL" is being set during a full ui install). The feature install states seem to be correctly set, but they aren't being appended to "ADDLOCAL" like they are for full-ui installs.

So, I guess my question is, how can I access the install states of features (in a deferred custom action) in a silent install? Since the "ADDLOCAL" method works in full-ui installations, I was hoping to use "ADDLOCAL" in silent installs also. But, it looks like I may have to change my implementation. The idea I have:
- Some way to populate "ADDLOCAL" during a silent install. Maybe I need an immediate custom action (so I can access the feature install states directly) that looks at the install state of each feature. If InstallState.Local=true, add that feature to "ADDLOCAL". Since the "ADDLOCAL" doesn't behave the way I expected in a silent install, I'm nervous about what ramifications this might have on the rest of the installation. I have to think about upgrades and patches also.

A couple things to keep in mind
- I use feature conditions to disable features. For example, I set the "Disabled if" field of "FeatureB" to B_LICENSED=0.
- I don't want to require ADDLOCAL=<Features> be passed in the command line.

Also, if anyone could explain (or point me to an article) what defining "ADDLOCAL" in the command line really does. I understand that it's a list of features that will be installed, but it seems to put the installer in some kind of special mode. The installation skips straight to the "ResumeDlg" and feature conditions are overridden. I'm not really understanding the relationship between the ADDLOCAL property and silent vs full-ui installations.


Any advice would be greatly appreciated.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Feature Install States and ADDLOCAL

Hi,
Maybe I need an immediate custom action (so I can access the feature install states directly) that looks at the install state of each feature.
Since the deferred custom actions cannot have access the installer's public properties, you need an immediate custom action to read the feature state and set its state in a windows installer property. For this, you can use either Session.FeatureCurrentState property or the Session.FeatureRequestState property, depending your specific scenario. Then, you can pass the related properties through the CustomActionData property to the deferred custom action.

Please take a look on the ADDLOCAL property article which may be useful to you.

Let me know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Feature Install States and ADDLOCAL

Please take a look on the ADDLOCAL property article which may be useful to you
Ya, I've read that article before. I was hoping there might be another article/blog post with some more detailed/in-depth information.
you need an immediate custom action to read the feature state and set its state in a windows installer property
Ok, that confirms what I was thinking might be necessary. I've gone ahead and implemented this. Instead of using a separate property to save the feature states, I've used ADDLOCAL. Whenever ADDLOCAL is empty (a silent install), my custom action will check the feature state of each feature, and, if InstallState.Local=true, will add it to ADDLOCAL. If re-using ADDLOCAL causes problems down the road, I'll just use my own property in place of ADDLOCAL.
If anyone else is curious, here is the code:

Immediate custom action that is run when ADDLOCAL="". I've added it after "Paths Resolution", but it can probably go somewhere else.

Code: Select all

string strAddLocal = "";

//For each feature, if the install state is local, add to ADDLOCAL
List<Microsoft.Deployment.WindowsInstaller.FeatureInfo> lstFeatureList = CustomActions.m_Session.Features.ToList();
foreach (Microsoft.Deployment.WindowsInstaller.FeatureInfo feature in lstFeatureList)
{
	if (feature.RequestState == InstallState.Local)
	{
		strAddLocal = strAddLocal + feature.Name + ",";
	}            
}

strAddLocal = strAddLocal.TrimEnd(',');

session["ADDLOCAL"] = strAddLocal;

Thanks.

Return to “Building Installers”