Starting in Visual Studio 2010 Beta 1, you can deploy multiple Office solutions in a single ClickOnce installer. For example, you can develop two Office solutions (one for Outlook and another for Excel) and combine these into a single installer with a single entry in the Add/Remove Programs list in Windows XP and the Programs and Features list in Windows Vista.
The Visual Studio Tools for Office runtime supports the ability to deploy multiple Office solutions in a single installer. However, Visual Studio still generates the ClickOnce application and deployment manifests for individual deployment. To deploy multiple Office solutions in a single installer, you must modify the application and deployment manifests to install multiple assemblies. This process is demonstrated in the Walkthrough: Deploying Multiple Office Solutions in a Single ClickOnce Installer topic in the MSDN Library.
Creating Multiple Office Solutions
To continue the example mentioned in the introduction, you can develop an Excel workbook project and an Outlook add-in project for .NET Framework 3.5. Then, to deploy both of these, create an installer project, which you can re-use later to add a third or fourth project. By keeping this installer project separate, it’s possible to keep the original files for the individual projects intact. In this example, the installer project is based on a Word document project, but the document isn’t being deployed. The following figure shows Solution Explorer with three projects, one installer project and two projects to deploy to end user computers.
Publishing the Office Solutions
After you add your code to the Excel and Outlook projects, publish the ContosoExcelWorkbook, ContosoOutlookAddIn, and then ContosoInstaller projects (in that order) to a folder on the development computer. You can right-click on the projects in Solution Explorer, and then click Publish. In this example, the publish directory is c:\publish.
Modifying the Application Manifest
Visual Studio generates an application manifest and deployment manifest for each project. The ClickOnce application manifest is a description of all the files included in the project. Additionally, this file describes how the Office application could load the assembly and run your code. By modifying the application manifest, you can describe files from multiple projects and install all specified projects. There are three different sections of the application manifest to modify: install dependencies, entry points, and assemblies.
These changes may appear lengthy, but it really amounts to a few copy-paste operations and adding four words to the application manifest.
Adding the Install Dependencies
1. In the c:\publish\Application Files folder, copy the contents of the ContosoExcelWork_1_0_0_0 and ContosoOutlookAddIn_1_0_0_0 folder into the ContosoInstaller_1_0_0_0 folder.
2. From the c:\publish\Application Files\ContosoInstaller_1_0_0_0 folder, open the three .dll.manifest files in the XML editor in Visual Studio.
3. Copy the <dependency> block for the Office customization assembly from the ContosoOutlookAddIn.dll.manifest and ContosoExcelWorkbook.dll.manifest files into the ContosoInstaller.dll.manifest file. This code specifies that the ContosoOutlookAddIn.dll and ContosoExcelWorkbook.dll files are part of the ContosoInstaller project.
4. Delete the <dependency> block for the ContosoInstaller.dll. This file is not part of the project, because you are only using the ContosoInstaller project to generate the application manifest template.
Adding the Entry Points
1. In the ContosoInstaller.dll.manifest file, delete the text between the <vstav3:entryPointsCollection> and </vstav3:entryPointsCollection> elements.
2. In the ContosoOutlookAddIn.dll.manifest and ContosoExcelWorkbook.dll.manifest files, copy the text between the <vstav3:entryPointsCollection> and </vstav3:entryPointsCollection> elements and paste them into the ContosoInstaller.dll.manifest file.
3. Add an id to the <vstav3:entryPoints> elements.
Adding the assemblies
1. In the ContosoInstaller.dll.manifest file, delete the text between the <vstov4:customizations xmlns:vstov4=”urn:schemas-microsoft-com:vsto.v4″> and </vstov4:customizations> elements.
2. In the ContosoOutlookAddIn.dll.manifest and ContosoExcelWorkbook.dll.manifest files, copy the <vstov4:customizations xmlns:vstov4=”urn:schemas-microsoft-com:vsto.v4″> and </vstov4:customizations> elements and paste them into the ContosoInstaller.dll.manifest file.
3. Add the id name to the <vstov4:customization> elements.
4. Save the changes in the ContosoInstaller.dll.manifest file, and close the ContosoExcelWorkbook.dll.manifest and ContosoOutlookAddIn.dll.manifest files.
Re-Signing the Manifests
To prove that yes, you really meant to make these changes to the application manifest, you must re-sign the application manifest with a certificate. Then, re-sign and update the deployment manifest to point to the new application manifest.
1. Copy your certificate to the c:\publish\Application Files\ContosoInstaller_1_0_0_0 directory. In this example, I’m reusing the temporary certificate created by Visual Studio because I’ll be installing this to a test computer. For production deployment, we recommend that you use a certificate obtained from a certificate authority.
2. In a Visual Studio command prompt, change to the c:\publish\Application Files\ContosoInstaller_1_0_0_0 directory. (You may have to open the command prompt in Administrator mode to re-sign the files in the c:\publish directory.)
3. Re-sign the application manifest with the following command:
mage -sign ContosoInstaller.dll.manifest -certfile ContosoInstaller_TemporaryKey.pfx
4. Change to the c:\publish directory
5. Re-sign the deployment manifest with the following command (on one line):
mage -update ContosoInstaller.vsto
-appmanifest “Application Files\ContosoInstaller_1_0_0_0\ContosoInstaller.dll.manifest”
-certfile “Application Files\ContosoInstaller_1_0_0_0\ContosoInstaller_TemporaryKey.pfx”
6. Copy the c:\publish\ContosoInstaller.vsto file to the c:\publish\Application Files\ContosoInstaller_1_0_0_0 directory.
Testing the Installer
1. Copy the c:\publish directory to a test computer.
2. In the publish directory, run the Setup.exe file or double-click ContosoInstaller.vsto.
3. Verify that ContosoInstaller appears in the Add/Remove Programs list in Windows XP or Programs and Features in Windows Vista.
4. Open the Excel workbook file and Outlook to verify that your code is running.
Feel free to leave comments and feedback about this new scenario at the bottom of this article.
Mary Lee, Programming Writer.