Visual Studio Installer Best Practices

   

You can provide your users with Microsoft® Windows® installer benefits, such as installation rollback, easier installations, and increased application stability, when you author installers with Microsoft® Visual Studio® Installer. To maximize the benefits of the Microsoft Windows installer in your installation packages, follow these best practices guidelines:

  • Maintain a separate installer component for each file you add to your installer project.

  • Use merge modules (.msm files) for both authoring and consuming shared code and components.

  • Do not use self-registration for installed components.

Maintain a separate installer component for each file

To ensure your component structure remains stable, include only one file in each component. Each file in your installer project should be its own component. This stabilizes component structure, which improves the stability of installation. Different products and product upgrades should not distribute the same component with modified structures — for example, including fewer, additional, or different files than a previous version of the component.

Note   Visual Studio Installer supports a maximum of 1,600 components in an installer project.

Whenever you redistribute a file you have already distributed in a component, you should distribute it in the same component. If you change the structure of a component after distributing it, you compromise the stability that component provides for installed products and future installations.

Relationship of component structure to successful installation

Installer components contribute to the increased stability of Windows installer-based installations and applications. The Windows installer maintains current and complete information about any component it has installed and can provide that information to the operating system. Tracking and sharing this information helps to eliminate conflicts between different versions of installed components.

Whenever a product is installed with an installer package (.msi) file, the Windows installer can determine if installed components already reside on the target machine. If a component already resides on the target machine, the installer compares that with the version to install and determines which version is newest. After making this comparison, the installer keeps or installs the newest version. By tracking and comparing component information, the installer ensures the most current version of a component is available for all applications that use it.

Use merge modules

Use merge modules (.msm files) to share components and files among installer package (.msi) files. As a single compound file, a merge module delivers all the files, resources, registry entries, and setup logic required to install and use shared code.

With Visual Studio Installer, you can both create and consume merge modules. Creating a merge module allows you to share your installer components and code with other Windows installers. Consuming merge modules enables you to use other developers' shared components and code in your installer projects.

Adhering to the component rules described in Maintain a separate installer component for each file and sharing files and components through .msm files helps to ensure the stability of applications installed with a Windows installer package. For this reason, use merge modules to distribute and update shared code used by your applications.

Do not use self-registration

With traditional scripted setup programs, self-registration was the accepted method for installing COM objects, and it is still a viable method. However, the Windows installer cannot perform a rollback installation and registration of self-registered COM objects, and it cannot advertise those objects. This is because self-registering COM objects do not pass their installation and registration information to the Windows installer, so the installer does not have the information necessary for rollback or advertisement.

To ensure the Windows installer knows enough about your installed COM objects for rollback or advertisement, you must install those COM objects in a manner compliant with Windows installer requirements. Use the Visual Studio Installer Associations editor to install Windows installer-compliant COM objects.