VSTO Outlook: the Complete Setup Solution
[Disclaimer: this is currently work in progress.. expect to find partial solution and some explanation]
UPDATE: Solution at the end:-)
The past week has gone and it feels as if I’ve moved one inch. Started with upgrading a Beta 2 solution to RC1. Not entirely trivial. If you can create a new project and move your code as much as possible to avoid problems with the VSTO vs. VS2005 stuff.
This means that what you’re about to read is RC1 based. Make no assumptions on this related to neither beta 2 or RTM.
CAS
Code Access Security is the primary issue on deployment. A lot of people have noticed the Code Access Security installerclass I wrote earlier and now it’s updated to also handle uninstall. It also creates more logical codegroup names and the code is easy to “steal” with all settings in private strings.
Get the C# source here.
Get the VB.NET source here.
In my opinion this type of class (possibly subclassed from Installer) should be an optional item for the VSTO Outlook VS2005 project template given that FullTrust is absolutely required for them to run. I know some admin should set the CAS policy in most cases, but in a lot of scenarios this is not viable. Administrators in small companies have no clue about CAS unfortunately, and for public domain scenarios end users sure won’t have a clue.
CAS is sadly just a small part of the picture of getting your plugin running. Read on to learn about your days work my last weeks work:
Prerequisites
There are a lot of questions related to VSTO Outlook deployment. The main reason is that there are so many actions that are completed for you when you’re debugging, and the client environment is a real jungle compared to the safe grounds of your devbox. In addition any faults in the prereq setup will cause a range of errors from subtle disabling of your plugin to brutal crashes.
The deployment of Outlook solutions are described at msdn2 here. Prerequisites are described here.
In short (?!) you’ll need to make sure these things are in place for your plugin to work:
- .NET Framework 2.0 (RC1)
- Microsoft Office 2003 w/Outlook
- Microsoft Office 2003 SP1 (or later)
- Microsoft Office 2003 Primary Interop Assemblies (O2003PIA.exe) (how-to)
- Visual Studio Tools for Office Runtime (vstor.exe) (Same version as .NET Framework!)
- Language pack for vstor (Optional)
- Registry keys for Outlook plugin (fixed by default VSTO Setup project)
- Code Access Security FullTrust grant to your assemblies
Any developer with normal instincts should react to this. So many things which are not in your power can make you get the blame for your software not working. This calls for some validating action.
The new VS2005 Setup Bootstrapper
In Visual Studio 2005 there is a new kid in town called the Bootstrapper. It’s revamped to handle more than just the .NET Framework and it’s customizable. MSDN Magazine posted an article which will give you the picture.
The idea here is to create and add Custom Prerequisites for everything that your plugin can possibly require to run. In my case I want to assert that the install only can run if the list above is verified. I also want to enable the user to install the missing parts with ease (at least the publicly available components) by deploying prerequisites either with my application or allowing for them to be downloaded from the vendor.
In my opinion custom prerequisites (at least validators) should be provided for Office related installs as part of the VSTO development experience. As you will learn, custom prerequisites is not really fun not that bad.
First go at Custom Prerequisites in Visual Studio 2005
I started out creating custom prerequisites for the Office 2003 PIAs and the VSTO Runtime.
Custom Prerequisites are defined in two main xml files located on the development box under the directory “\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\”.
The main part of the template is a product.xml file and a package.xml file. Their schema is described here, but it seems like the documentation is somewhat out of sync with the RC1 bits. The templates can define do various checks and install prerequisites. You can define search for registry keys, the filesystem, search for assemblies in the GAC and so forth. You can also define validation rules on operating system and usermode (admin). Anything you can’t do out of the box can be done by writing an unmanaged util to do some checking and calling it from the custom prerequisite (like dotnetfxchk.exe). All in all you’ve got the tools to validate things before the bootstrapper allows your msi to run.
The custom prerequisites will appear in the Prerequisites dialog (click to view) of the Setup Project properties.
My current templates can be downloaded here and here. Currently they got a couple of problems causing them not to install prereqs, but you’ll get the idea of the xml format. Be aware of the references between elements. For example the DisplayName attribute of the Package element refers to the String element with the Name attribute set to DisplayName.
There also seems to be some overlap that I do not yet comprehend between the product.xml schema and the package.xml schema. The package.xml is for localized stuff. Try only using this for strings as long as you can. The rest goes into the product.xml.
When you’ve selected the prerequisites the Setup Project will include them in the bootstrapper setup.exe file. The setup.exe will then assert all the rules of the prerequisites before running the msi.
I’ve created custom prerequisites for “O2003PIA.exe” and “vstor.exe”. You can have a look at them here and here. To test them you’ll need to extract to the directory mentioned above and add the binaries yourself. Links to download are in the package.xml files.
They’re not completely functional yet, and I’m hoping to get some feedback on them.
The problem right now is that the bootstrapper don’t run the prerequisite packages, neither if I include them with the install or direct to vendors website. I suspect there is something wrong in the package.xml files. The log from the install not behaving but calling at least one of my custom prerequisites can be found here.
Friday night: to be continued…