In the first part of this series, we went through the steps to create a simple Outlook 2010 add-in, how to build a custom ribbon, and finally the backstage area. But what use is your add-in unless other people can use it too? In part 2, we will look at the steps to create a setup package so that you can distribute your add-in to others.
Returning to the solution you started in part 1, you will now need to add a Setup Project. I’ll call mine “SetupMyOutlookAddIn”. When the project has loaded in, Visual Studio will bring up the File System screen of your Setup Project. We will need to make a few changes here:
We’ve now effectively told the setup project to install all our application goodness to the user’s AppData folder (Normally C:\Users\[username]\AppData in Windows 7, for example). We are doing this as this is a safe, sandboxed location that requires a minimum of privileges to install to. Here’s roughly how your screen should look now…
Now, we need to remove some of the .dll files that were added as Primary Output (because we do not need them). In Solution Explorer:
There are now 2 files you need to reference explicitly in your setup project. These are files that are created when you build your solution – so you will need to point to the release folder. You may use debug if you wish – just remember you are pointing there. For production software, you should point to release. So, in the File System window of your setup project:
Your File System window should now look something like this:
To get our add-in working, we will need to add registry keys. When you are developing the solution in Visual Studio, this happens automatically in the background, so it can be a surprise that you will need to do it explicitly! The keys we are creating will be saved to: HKCU\Software\Microsoft\Office\Outlook\Addins.
Open the Registry Panel in your Setup Project, then:
Here’s how your Registry screen should now look:
Now, we need to make sure that the Setup.exe you produce will check for prerequisites on the client system. This can be done by:
We’re pretty much done! A few things you may want to change:
Build your add-in, and then right-click your Setup Project and select Install. The next time you open Outlook, you should be prompted to allow your new add-in to run!
Written by Matthew Farmer