Adding the Office Primary Interop Assemblies as a Prerequisite in your ClickOnce installer (Mary Lee)

When you use ClickOnce in Visual Studio 2008 to deploy your Office solution, you can include prerequisites such as the .NET Framework 3.5, the Visual Studio Tools for Office system 3.0 Runtime, and Windows Installer 3.1.  However, the primary interop assemblies (PIAs) for the 2007 Microsoft Office system are not automatically listed in the Prerequisites dialog box. 


Fortunately, you can add the PIAs to the Prerequisites dialog box. The following procedure adds the 2007 Microsoft Office Primary Interop Assemblies to the Prerequisites Dialog Box. This procedure may look lengthy, but you only have to do it once.


1.  Download the OfficeVSTO2005SEWindowsInstallerV3.msi sample, which is part of the deployment whitepaper at Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer (Part 1 of 2).


2. Install OfficeVSTO2005SEWindowsInstallerV3.msi.


3. Copy the contents of %ProgramFiles%\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample Version 3\packages to %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages


4. Compile the component checker. This step checks if the computer has the correct version of Office installed to match the PIAs that are being installed.



a) Open a Visual Studio command prompt



b) Change directories to %ProgramFiles%\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample Version 3\projects\Checks


c) Type the following command: cl.exe /Oxs /MT /GS ComponentCheck.cpp advapi32.lib



d) Copy ComponentCheck.exe to the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA folder and the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2003PIA folder.


5. Download and extract the Office 2007 PIAs from 2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies.


6. Copy the o2007pia.msi file to the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA folder.


7. In VS2008, on the Project menu, click ProjectName Properties.


8. Click the Publish tab.


9. Click the Prerequisites button to open the Prerequisites dialog box.


You should see the PIAs listed in the Prerequisites dialog box like the following image. Because the package.xml file does not define a HomeSite (a location to download the file), you will see a build warning.  Even if you have selected Download prerequisites from the component vendor’s web site, the PIAs will go into a directory alongside your solution installer.


Prerequisites


If you want to learn more about adding your own entries to the Prerequisites dialog box, see Adding Custom Prerequisites.


For more information about common problems when deploying the Office primary interop assemblies, see http://blogs.msdn.com/vsto/archive/2008/05/20/common-pitfalls-during-pia-deployment-and-installation.aspx.


For troubleshooting assistance, try the VSTO Power Tools, a suite of tools to help you develop and deploy Office solutions. For example, you can use the VSTO Troubleshooter to examine end user computers for missing prerequisites.


Mary Lee, programming writer.