How to use Advanced Installer for an Excel-DNA Project

1. Introduction

Excel-DNA is a game-changing solution for development of XLL Excel add-ons in C# without VSTO abstracting away majority of the C++ implementation details.

While a simple XLL add-on requires no registration or installation, the more advanced XLL add-ons with rich UI components demand an installer for setting up the environment.

Advanced Installer is an installer enabling you to deliver professional installers with minimum effort. I have been using it for a number of years with full satisfaction.

2. The Importance of Distributing a MS Excel Add-on with an Installer

For small projects, Excel-DNA provides an elegant way of distributing the output add-ons by packing all required DLLs into one big XLL file (one for 32-bit and one for 64-bit version of MS Excel).

The XLL file(s) can then be just copied on the target computer and opened directly in Excel without manual modifications of any system registry or other changes.

Once the add-on becomes larger and once the number of DLL libraries it depends on increases, this approach becomes not optimal because:

  1. Ballooning of the total distribution file sizes due to the inclusion of packed identical DLLs in both the 32- and 64 bit XLL versions. Each Excel add-on needs to be distributed in both 32- and 64- bit versions and packing all libraries into the XLL files requires all the libraries to be packed in both 32- and the 64-bit version XLLs, effectively distributing of each DLL library twice. This becomes an issue once the Excel-DNA addon depends on complex UI components with typical sizes of tens of megabytes. Then it may become advantageous NOT to pack all the libraries into the output XLL files.
  2. Inability to pack native unmanaged DLLs with Excel-DNA packer. Once the Excel add-on starts depending on some native unmanaged optimized library, e.g. a numeric math one or SQLite one, the distribution requires to distribute separately a 32-bit and a 64-bit version of the native unmanaged optimized libraries. Excel-DNA packer doesn’t offer this feature and the solution has to be distributed as an XLL file with a couple of DLL copied alongside.
  3. Inability to pack effectively the database and other files. Though it’s possible to pack database and other required files as resources in an Excel-DNA addon and then unpack at runtime, this solution is not optimal since this increases your code base (have as little code as possible!) and since there is a performance cost for this. Separate distribution is much preferred.
  4. Install every time Excel opens. Though it’s possible to install an Excel-DNA add-on using AutoLoad method, so that the user would have to just launch an Excel-DNA XLL file in Windows Explorer or in a similar way, such a method is not recommended as it increases the initialization time of launching Excel and is a pure waste of time – why should the add-on be installed (or checked if it’s installed) each time you launch Excel? Thus, automatic installation of the add-on only once is a better way.
  5. Not Supported Auto-Updates. Excel-DNA packer doesn’t provide any native method of auto-updating of the add-ons. A solution which provides auto-updates is then much welcome.
  6. Manual Management of Installation. Since all you need to do is to manually copy the XLL files, you have to take care of all folder operations which may be inconvenient, at best. A one-stop Installer does the job much more elegantly.
  7. No support for Pre-Requisites. The more and more advanced the add-on gets, the longer and longer the list of the frameworks it depends on gets. Apart from crashing or possibly an error message, Excel-DNA has no way to check or even to remedy the situations, such as that the required .NET version is not present or that you do not have the right libraries installed. Most installer solutions do provide a way to check the pre-requisites and to download and install automatically the missing components.

3. Why Advanced Installer

While there are a number of commercial (e.g. InstallShield) and public source installers (e.g. WIX – check this link for an Excel-DNA example) available, I sincerely believe that Advanced Installer stands out for the following reasons:

  1. It’s forward looking in provided functionality – not many installers offer, for example, a native Auto-Update support
  2. It’s easy to set up and to use – you can set up a professionally looking Installer in just minutes in a very intuitive UI
  3. It has excellent support – you get answers to you all your questions within a few hours
  4. It’s much cheaper than competitive solutions

4. The Editions of Advanced Installer

Advanced Installer is provided in a number of editions (see the comparison), starting with the Free Edition which is suitable for basic setups.

This tutorial describes the Advanced Installer Professional Edition.

5. Step-By-Step Instructions for Creating Advanced Installer Project for an Excel-DNA Solution

For an Excel-DNA add-on, I recommend creating two projects – one for the installer itself and one for the auto-updater.

The output of the Installer project is an EXE (or an MSI) file. The output of the Auto-Updater is a TXT file which contains the updates definition – this file is then being polled every day by your application to see if there has been an update.

The set-up is straightforward.

5.1 The Installer Project

Fire up Advanced Installer, choose the Professional Template …

Click to create a project …

Set up the project definitions – Name etc. – …

Specify the URL of the txt file generated by the Auto-Updater …

Set up the pre-requisites for the Product, e.g. the .NET 4.5 and what to do if it’s missing – here the installer packs the Web (very small) .NET 4.5 installer to the installation file …

Install only if Excel is installed …

Specify the target file hierarchy – what files and directories to copy to the installation target directory …

Choose the Installer Theme …

Set up conditions to find out whether the target computer is running Office 32- or 64-bits …

Carry out pre- and post-installation custom actions. These actions are shared among uninstallation, installation and maintenance so make sure that you tick off the right checkboxes for your actions.

For all uninstallation, installation and maintenance, first, detect if there is an Excel open, warn the user that it will be closed, close the Excel …

Now, let’s install the add-on – different procedure for 32- and 64- bits as the XLL files are named differently …

And finally, kill all open Excels, just in case …

Now, you’re able to Build the Installation EXE file …

Notes:

  1. For more complex scenarios, I recommend creating a separate EXE program installing and uninstalling the XLL into / from the System Registry
  2. Advanced Installer also offers you to sign the resulting installation file with a digital signature
  3. It is also possible to set up the installer so that the resulting installation file is a MSI or a light installer which downloads the current version from the Internet

5.2 The Updater Project

Open a new Advanced Installer Project …

Click on the Update button which asks you for the path to the EXE of the installer created in the previous subchapter and specify the version details …

Specify the description of the changes in the update …

And finally, add to your C# solution a call to the “updater.exe /silent” on start and your updater is up and running!

For the details on the Updater, please, refer to the Advanced Installer’s Updater Documentation

Advertisements
Menu