Add-in Express vs. VSTO: Office add-in deployment
Planning the deployment of any software product is something most of us leave right to the end of the project. It makes logical sense to do so, everything that needs to be built is built and we know what we need to deploy. Unfortunately, the setup program is also quite often something we do quickly, trusting the Visual Studio tools to take care of all the prerequisites and dependencies.
Visual Studio does a pretty decent job of building setup projects when it comes to non-VSTO projects but one of the major pain areas with VSTO is deployment. In this post, I’ll walk you through some of the steps in building a setup project for a simple VSTO Office Add-in and then I’ll show you how Add-in Express builds the setup project for you. Visual Studio 2005 to 2010, including the Visual Studio Express editions, as well as the latest Visual Studio 2012 are supported:
- Building a VSTO Office add-in MSI installer
- Creating an add-in ClickOnce installer in VSTO
- Building an Office add-in MSI installer with Add-in Express
Building a VSTO Office add-in MSI installer
So you’ve built your next ground-breaking Excel Add-in using VSTO and you’re ready to release it unto an unsuspecting world. The final step in your Excel Add-in World domination plan is to build an installer that your end-users will use to get your add-in running on their machines.
Creating the Visual Studio setup project
In Visual Studio you can add a setup project to your solution as you would any project type: via the Add New Project menu. You then select the Setup Project template.
The setup project is added to your solution.
Add Project output and manifests
Next, as with any project you need to add the project output to the setup project by right-clicking on the setup project name and selecting Project Output… from the Add menu option.
The setup needs to deploy the application and deployment manifest. You must add these two files to your setup project’s output folder. To do this right-click on the setup project and select File… from the Add menu item. Select the .vsto and .manifest files in your add-ins’ Bin folder.
Configure the registry
Microsoft Office looks for extension in the Windows registry so in order for your add-in to work, you must create registry keys that specify which user on the PC may use the add-in as well as which Office application should load the add-in. Personally, I don’t mind having to work with the registry but, the windows registry is like the bad part of town…you hardly ever venture there and only if you absolutely have to.
Make sure your setup project is selected in the Visual Studio Solution Explorer and click on the Registry Editor button in the Solution Explorer toolbar.
With the registry editor open, add the following key hierarchy under the User/Machine Hive
Add the following values under the WorldChangingExcelAddin key:
- LoadBehavior; and
Description and FriendlyName is self-explanatory. Setting the LoadBehavior value to 3 will cause the add-in to load when the host Office application starts up. The Manifest value should point to the .vsto file in the target installation directory.
Office 2010 64-bit looks for add-in registry keys under the 64-bit hive. To add the registry entries for your add-in under the 64-bit registry hive, you have to set the setup projects’ target platform to 64-bit. This causes a problem when you need to support both 32 and 64-bit installations and results in you having to build two versions of your setup, one for 32-bit editions of Office 2010 and another for 64-bit.
Visual Studio Tools for Office runtime requirements
Microsoft Office 2010 also contains the Visual Studio Tools for Office 2010 runtime, if your add-in targets the .Net framework 3.5, it should run without the need for your setup program to install it. However, if your add-in targets the .Net framework 4, you would need to create a setup launch condition to check for the presence of the VSTO 2010 runtime.
This is of course only true if your add-in target Office 2010, for any earlier versions of Office you would need to deploy the appropriate VSTO runtime.
Primary Interop Assemblies (PIA)
You would also need to deploy the Office Shared Primary Interop Assemblies or PIA. In order to check whether the user already has the appropriate PIA installed, you need to create a custom launch condition if your add-in targets Office version earlier than 2007.
In the case of your add-in targeting Office 2010, you do have the option to download and install the Microsoft Office 2010 Primary Interop Assemblies (PIA) Bootstrapper, which will give you the option to add the Office 2010 PIA as a prerequisite. The Office 2007 PIA can also be added as a prerequisite.
Creating an add-in ClickOnce installer in VSTO
You do have the option to give your users the ability to install your VSTO Add-in using ClickOnce and from what I’ve read; it seems to be the preferred option.
To create a ClickOnce installer, right-click on your project and select Properties from the context-menu. On the Publish tab, you can specify the location you would like to publish the add-in to as well as the URL users would install it from.
As with the MSI installer you can specify the Prerequisites and use the Options to specify the add-in Load Behaviour.
Building an Office add-in MSI installer with Add-in Express
Creating an installer for your Office add-in that was built with Add-in Express could not be simpler, as with almost all Add-in Express components, it takes a few mouse clicks.
Creating the Visual Studio setup project
In order to create a setup project, simply right-click your project in the Visual Studio Solution Explorer and select Create Setup Project from the context-menu.
Add-in Express will start a New Setup Project wizard that will guide you through the process of creating an MSI installer project, where you can specify details such as the Title, Description and Localization of the add-in.
Your choice of installer and options
The Add-in Express setup projects also supports InstallShield as well as any 3rd party installers. You also have full control over the installation with custom actions as well as full support for per-user or per-machine deployments.
Adding project output and configuring the registry
The New Setup Project wizard automatically adds the project output and necessary files to the setup project.
At this stage your setup project is ready to be built and deployed. Add-in Express takes care of creating the necessary registry entries for you.
Version and platform independent
With the setup project Add-in Express generated for you, you automatically receive a deployment package that supports all Office versions and platforms (x86 and x64), this makes deployment much easier as you only have one setup project to distribute for all configurations.
ClickOnce or ClickTwice : )
Building a ClickOnce installer for your Add-in Express add-in is just as easy as building a MSI installer. Simply select Publish ADX Project from the project context-menu in the Visual Studio Solution Explorer. A Publish dialog will give you the ability to quickly build a ClickOnce installer or an installer for the Add-in Express MSI-based web deployment technology known as ClickTwice : )
ClickTwice : ) enables users and administrators to run MSI installation packages from either the internet or their own intranets. Where ClickOnce can only target non-administrator installations, ClickTwice : ) provides an alternative to install and update per-user and per machines Office extensions.
I have to be honest, I knew I was spoiled with Add-in Express’ ease of use and products, but I never realized just how spoiled when I had to create a MSI installer for VSTO. There are so many things to consider and manual actions to be taken into account that you can easily miss something important.
It is also extremely frustrating that the last step to releasing your product and getting it to market is such a big deal when building the VSTO setup project. With Add-in Express building setup projects is really, click and go.
Save yourself a lot of aggravation and get that super world-class Office add-in out of the door with the help of Add-in Express.
Thank you for reading. Until next time, keep coding!
Last updated: 6-Feb-2013
Add-in Express vs. VSTO:
- Part 1: Add-in Express vs. Visual Studio Tools for Office
- Part 2: Version neutrality for your Office extensions
- Part 3: Visual designers for Office Ribbon UI customization
- Part 4: Backstage View and context menu visual designers
- Part 5: Outlook regions
- Part 6: Custom Office task panes
- Part 7: Office add-in deployment
- Part 8: Microsoft Office developer happiness