Microsoft KB Archive/306439

= How to create a nested .msi package =

Article ID: 306439

Article Last Modified on 7/23/2006

-

APPLIES TO


 * Microsoft Windows Installer 1.1
 * Microsoft Windows Installer 1.2
 * Microsoft Windows Installer 2.0

-



This article was previously published under Q306439



SUMMARY
A nested installation action installs another Windows Installer package during a currently running installation. This article shows how to create a package that performs a nested installation.



MORE INFORMATION
You can add a nested installation to a package by authoring a nested installation action into the CustomAction table and scheduling this custom action into the sequence tables. The Target box of the CustomAction table contains a string of public property settings that are used by the nested installation. The Source box of the CustomAction table identifies the nested package. A nested installation action can only reinstall or remove an application that has been installed by the current application's installation package.

The type of nested installation action is specified in the Type box of the CustomAction table. Depending on the custom action type, the package for the nested application can reside in &quot;substorage&quot; of the main package, as a file at a location specified by a property, or as an advertised application on the user's computer.

The following is an example of how to create a type 7 nested installation custom action. The example uses a tool called Orca (this tool is packaged with the Windows Installer SDK) to edit the .msi package because Visual Studio Installer cannot created nested installation custom actions. (For more information on Orca, see the &quot;References&quot; section). The nested installation involves two .msi packages. The following example uses Basic.msi as the parent .msi package and Nest.msi as the nested .msi package.  Use the Msidb tool (this tool is packaged with the Windows Installer SDK) to add the Nest.msi package as a &quot;substorage&quot; of the Basic.msi file. The command line is:

Msidb -d Basic.msi -r Nest.msi

This will add Nest.msi to the Basic.msi file as substorage. No dialog box will appear to confirm that this was successful, but the file size for Basic.msi will increase.

Note You cannot add Nest.msi as substorage by using the Binary table in Orca. When you add a file to an MSI through the Binary table, the file is added as a binary stream, not as substorage. Files added by the Binary table cannot be referenced by the source column of the CustomAction table. Use Orca to open Basic.msi. Locate the CustomAction table and type the information for the custom action. If you need to pass any public properties to the nested package, you can use the Target box for this. There will be two custom actions, one for install and one for uninstall (which has a target of &quot;REMOVE=ALL&quot;). The following is an example CustomAction table:  Schedule the custom action in the InstallExecuteSequence table. There are conditional statements for both the Install and Uninstall actions in the InstallExecuteSequence table. The condition will tie to a component for the Install (>2) and Uninstall (<=2). You could also tie these actions to a feature or another property. The nested installation custom action must be placed before InstallFinalize. If you use a component or a feature as a condition, the custom action must be placed after CostFinalize. The following is an example InstallExecuteSequence that assumes there is a component in Basic.msi named &quot;Comp_1&quot; and conditions the nested installation based on the state of Comp_1): 

Although you can create a nested MSI installation, there are drawbacks to doing this. These drawbacks include the following:
 * Nested Installations cannot share components.
 * An administrative installation cannot contain a nested installation.
 * Patching and upgrading will not work with nested installations.
 * The installer will not correctly cost a nested installation.
 * Integrated ProgressBars cannot be used with nested installations.
 * Resources that are to be advertised cannot be installed by the nested installation.
 * A package that performs a nested installation of an application should also uninstall the nested application when the parent product is uninstalled.

