Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Conditionally install a feature


24 replies to this topic

Jann

Jann
  • Members
  • 35 posts

Posted 28 January 2002 - 14:06

I want to install a feature depending on whether a checkbox has been ticked or not.  I want to do this without using the Custom Install dialog.

The checkbox property is RESOURCE1 and returns 1 if checked.

If I create a CA which sets FEATURE1 = RESOURCE1 then put after AppSearch in the sequence what do I need to set as the installlevel and condition in the feature properties?

I have tried a few options including Install Level = 150.

Level              Condition
100                  FEATURE1="1"

Thanks



Dave I

Dave I
  • Members
  • 195 posts

Posted 05 February 2002 - 12:08

Jann,
          Have a look at the position of the "CostFinalize" action in your User Interface sequence.  By default the CostFinalize action is before the InstalWelcome (and Dialog stream.) This is so that lists of available features can be displayed in the CustomSetup dialog.

The problem is that the CostFinalize action also resolves the values of properties, so I guess what is happening is that the value of your property is being resolved before it even gets to you user interface dialog.

What you need to do is move your InstallWelcome... sequence before the costing process, so plonking it before CostInitialise should do it.  Your Property will be set by your UI and then the value will be resolved.

Let me know if you have anymore problems, I have replaced the CustomSetup option with my own dialog sequence as I have described.


Augusto

Augusto
  • Members
  • 32 posts

Posted 06 February 2002 - 11:17

Thank you very much Dave. I had the same problem and was getting rather confused. Your tip did solve it.
Thanks again.

Augusto

Augusto
  • Members
  • 32 posts

Posted 06 February 2002 - 16:04

This method has a small problem though:
If you intend view or modify fetures during your user interface sequence (display of the Custom Install Dialog, for example), you will not succeed. That's because the CostFinalize Action has to be performed before anything can be done with the feature table.

So, now, how do I walk this around? Any ideas?

Thanks for the help.


Dave I

Dave I
  • Members
  • 195 posts

Posted 06 February 2002 - 16:17

Your right.  This fix is only suitable if you are replacing the Custom setup dialog with your own dialog sequence of radio buttons, checkboxes, etc. meaning that lists of features dont need to be displayed.

In response to a radiobutton PRODUCTDATA="TRUE" or "FALSE" you could do an MsiSetFeatureState in a customaction in the execute sequence.

Basically if you are using the CustomSetup dialog or want to show a list of features in the UI ignore me.

Any more help letm me know,
Dave


Augusto

Augusto
  • Members
  • 32 posts

Posted 07 February 2002 - 10:54

I'll try to create my own "Custom Dialog". I just wonder: This basically means that during UI SSequence one cannot set properties and display the Custom Dlg. That is in my world a "bug" of the software or technology in use, a biggy I'd say ...
I'll try to find out.
Thanks for your help.

Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 07 February 2002 - 13:03

In response to the original post from Jann.

There are ADDLOCAL, ADDSOURCE and REMOVE control events that can be used to add, run from source or remove a feature.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 12 February 2002 - 07:29

Augusto:
The concept of feature conditions is not for selecting features via user interface. teh control events that Ian mentioned are intended for this purpose.
Feature conditions can be used to hide a feature that is inappropriate on a certain operating system, or to change the default selection state of a feature depending on some other software being installed (as detected with AppSearch) and the like.

vnadoda

vnadoda
  • Members
  • 35 posts

Posted 19 February 2002 - 22:37

Hi guys,
I had the same problem, I mean not able to install feature conditionally. I am using dialog with check boxes to control feature installation.
So as suggested before, I move InstallWelcome dialog before CostFinalize Sequence.
But Then I am not able to show Installation directory in Destination folder dialog.
I think That is becuase CostFinalize event also resolves properties such as INSTALLDIR.
So is there any solution or workaround for this prob?

Thanks...
-vPuL


Dave I

Dave I
  • Members
  • 195 posts

Posted 20 February 2002 - 09:37

Again, same problem I had.  Any deviation from best practices or the "Windows Installer way"  quickly snowballs into more and more workarounds.

Unfortunately I cannot see any other way, I can tell you what I have done, it may not be universally recommended but it works.

1.) Remove the event SetTargetPath from the InstallChangeFolder dialog, OK button (the directories are not initialised so this will fail.)  

2.) Created an intermediate Public property (e.g. TEMPINSTALL) and on the DestinationFolder dialog, ChangeFolder button replace INSTALLDIR in the following condition with TEMPINSTALL:

[BrowseProperty] [INSTALLDIR]    1

You may want to give this property a default value in the property manager.  Throughout the UI use [TEMPINSTALL] to display the user selected folder.

3.)  Create a Type 35 CA, "Set a Directory" in the wizard with a source INSTALLDIR and destination [TEMPINSTALL], this replaces the SetTargetPath we removed earlier.  This should do the trick.

Like I said earlier, I know its not the correct way of doing things so please no posts moaning at the methods, it worksfor me, and if it works for you thats all that matters.

Good Luck,
Dave.


Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 20 February 2002 - 10:21

When I had this problem I used two custom actions to solve the problem  My features are called VCDS_IP and VCDS_IPX.  They install a driver for UDP or IPX network protocols..

UINT __stdcall AddIP(MSIHANDLE hInstaller)
{
MsiSetFeatureState(hInstaller, "VCDS_IP", INSTALLSTATE_LOCAL);
MsiSetFeatureState(hInstaller, "VCDS_IPX", INSTALLSTATE_ABSENT);
return ERROR_SUCCESS;
}

UINT __stdcall AddIPX(MSIHANDLE hInstaller)
{
MsiSetFeatureState(hInstaller, "VCDS_IPX", INSTALLSTATE_LOCAL);
MsiSetFeatureState(hInstaller, "VCDS_IP", INSTALLSTATE_ABSENT);
return ERROR_SUCCESS;
}

I created two custom actions
Action : AddIP
Type: 1
Source: KickStart
Target AddIP

and

Action:AddIPX
Type: 1
Source: KickStart
Target AddIPX

I added these actions to the execute sequence just after CostFinalize with condtions NETWORKTYPE="IP" and NETWORKTYPE="IPX" respectively.  NETWORKTYPE may be set by a radio button in the UI sequence, on the command line, or with a radio button in the Admin Install UI sequence.
I also have validation condtions to ensure NETWORKTYPE has a valid value.


vnadoda

vnadoda
  • Members
  • 35 posts

Posted 20 February 2002 - 18:09

Hi Dave,
Thanks a lot for excellent workaround!!!
It works for me also..so no post moaning...
But still There is one prom with me...
When I clicked OK button in InstallChangeFolder dialog, it gives me error saying:
Internal error 2812: <Name of my Custom action>
I completed all steps you mention before.
So what I am missing, here..??
Any Idea?

Thanks..

-vPuL


Dave I

Dave I
  • Members
  • 195 posts

Posted 20 February 2002 - 18:20

Apologies, I just read back my instructs and I missed a bit out!  Place the Type 35 CA -  to change the folder in the execute sequence just after CostFinalize.  I actually meant it replaces the SetTargetPath indirectly.

The InstallChangeFolder, OK button should now only have the entry:
EndDialog            Return             1


Let me know if you have anymore problems,
Dave


vnadoda

vnadoda
  • Members
  • 35 posts

Posted 20 February 2002 - 18:32

Thanks a lot dave...
Everything is working fine....no mopre probs...

-vPuL


vnadoda

vnadoda
  • Members
  • 35 posts

Posted 26 February 2002 - 20:06

Hi Ian Blake,
To add feature, I am trying your code.
Can I use MsiSetFeauterState function directly in installscript?

Thanks..
-vPuL


Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 26 February 2002 - 23:27

You can, all the MsiXXX functions can be called from Installscript.  I am afraid I can not help you with the details but I am sure someone else can.


vnadoda

vnadoda
  • Members
  • 35 posts

Posted 26 February 2002 - 23:35

Thanks Ian Blake,

I am trying to use it.
Biu it hangs the Installer during execution of that code line.
Is there any special way to use it?

Please help me out...

thanks..
-vPuL


Ajawl

Ajawl
  • Members
  • 54 posts

Posted 07 February 2003 - 14:54

Hi,
I have the same problem and now I will try the solutions.
I know that the features conditions are evaluated during the COST in the UISequence. So, any change using check boxs(after the COST) in the value of the properties which evaluate the state of a feature will not take effect.
But the feature state should be evaluated again during the ExecuteSequence, where there are again the COST actions. But it does not work! The state of the features is not reevaluated during the ExecuteSequence! Does anybody have any explanation?  

Thank you very much,
Ajawl

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 07 February 2003 - 15:24

Costing will only be performed a second time (in execute sequence) on NT4/2000/XP, but not on 95/98/Me. The reason is that costing is only performed once per process. While on the 9x both sequences run in the same process, on NT family user interface and execute sequence run in different processes.
Even on NT this would cause incorrect disk space requirements calculation in the user interface sequence.

You'd better use AddLocal and Remove control events.

Ajawl

Ajawl
  • Members
  • 54 posts

Posted 10 February 2003 - 11:54

Hi Stefan,
Thank you for your help, but costing is still not being performed a second time during the execute sequence on Windows 2000 (I have not yet tested in other operating systems). The feature condition is still being evaluated with the property's value which was set before the costing in the UI sequence.When I set a property during the UI sequence (after costing), this value and the respective feature condition is not reevaluated during the execute sequence. If you want, I can send you a LOG file and the project which I have used to test (How could I send you?).

Thank for your attention,
Ajawl

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 10 February 2003 - 11:59

Is your property in all UPPERCASE letters?

Again, this is not the "proper" way of doing it. I recommend you use AddLocal and Remove control events.

Ajawl

Ajawl
  • Members
  • 54 posts

Posted 10 February 2003 - 12:33

Hi Stefan,
Yes, the property is in uppercase letters and is passed to the execute sequence with the new value by the command line during the ExecuteAction. The property's name is SELECTEDFEATURE.
The command line executed by the ExecuteAction is:  

Aktion gestartet um 09:44:05: ExecuteAction.
MSI © (74:48): Switching to server: SELECTEDFEATURE="B" INSTALLDIR="C:\Programme\Your Company Name\Default\" TARGETDIR="C:\" REINSTALLMODE="vomus" CLIENTUILEVEL="0" SOURCEDIR="F:\Ihr Projektname-1\Produktkonfiguration 1\Release 1\DiskImages\DISK1\" ACTION="INSTALL" EXECUTEACTION="INSTALL" ROOTDRIVE="C:\" SECONDSEQUENCE="1"  ADDLOCAL=NewFeatureA

The feature NewFeatureA has the condition SELECTEDFEATURE="A", and the feature NewFeatureB has the condition SELECTEDFEATURE="B". You can see that ADDLOCAL=NewFeatureA, because the initial value of SELECTEDFEATURE is "A" and this condition was evaluated during the costing in the UI Sequence. After the costing during the execute sequence, the NewFeatureB should be installed instead NewFeatureB. But it does not happen.

I know that there is this other way using ADDLOCAL and REMOVE, but my setup has many features. For this reason, I think that the  cleanest way would be using feature condition.

Thank you again,
Ajawl

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 10 February 2003 - 12:57

What entry does your log file show for action CostFinalize in execute sequence?

Ajawl

Ajawl
  • Members
  • 54 posts

Posted 10 February 2003 - 15:10

The CostFinalize action returns just the paths of some directories. It follows just a part of the log for the action CostFinalize in the execute sequence:

MSI (s) (A4:F8): Doing action: CostFinalize
Aktion gestartet um 09:44:37: CostFinalize.
MSI (s) (A4:F8): Note: 1: 2262 2: Patch 3: -2147287038
MSI (s) (A4:F8): Target path resolution complete. Dumping Directory table...
MSI (s) (A4:F8): Note: target paths subject to change (via custom actions or browsing)
MSI (s) (A4:F8): Dir (target): Key: TARGETDIR , Object: C:\
MSI (s) (A4:F8): Dir (target): Key: WindowsVolume , Object: C:\
.........
MSI (s) (A4:F8): Dir (target): Key: DIR25 , Object: C:\Programme\Your Company Name\
MSI (s) (A4:F8): Dir (target): Key: INSTALLDIR , Object: C:\Programme\Your Company Name\Default\
Aktion beendet um 09:44:37: CostFinalize. Rückgabewert 1.

Thank you for your attention,
Ajawl

Ajawl

Ajawl
  • Members
  • 54 posts

Posted 12 February 2003 - 14:37

Hi,
I tried everything that I could. For me it seems to be a bug in the windows installers. I tried with windows installer 1.x and 2.x and I have always the same result: the feature condition is not reevaluated during the execute sequence.
I will be glad if someone has any idea.

Thank again,
Ajawl