[dba-VB] ClickOnce: Adding and installing fonts (or anything else)

Gustav Brock Gustav at cactus.dk
Fri Oct 24 06:20:32 CDT 2008


Hi all

As you may be aware, an application published with ClickOnce doesn't "install", it just loads and runs on the user's machine, and "disappears" when he/she closes it.

So what to do if you need a special font for your application?

You _can_ include code in your app to create the font file and call the API to install it, but a lot of code is required, indeed if you wish to add code to catch all the possible error sources like missing admin rights and so on. 
So I googled for other methods and found that you can include nearly anything as a "prerequisite" for running your application. These prerequisites will be added to your publish page with an option to download and install these before launching your app, while - on the other hand - your app will be adjusted to check for a successful installation of each of the prerequisites - if any is missing, the app will refuse to launch with a message about what is missing.

So an msi installer should be created to install the font. To create this, open a new setup project, add nothing more to this than the "Special folder" Fonts, and add the font file to this folder. Build the msi install package.

Next question, how to include your font installer as a prerequisite? For this to happen, a bootstrapper package must be created. These are typically located in:

  C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

Here you'll see those packages listed in the Prerequisites' list box where you can mark those you need for your app. To turn your setup file into a bootstrapper package, all you need is to create two manifest xml files as you can see if you browse the other packages' folders.
However, creating these xml files is not a beginner's job even though it is documented at MSDN:

  http://msdn.microsoft.com/en-us/library/aa730839(VS.80).aspx

Luckily, as you whisper OMG, you find a tool for this, BMG, Bootstrapper Manifest Generator:

  http://code.msdn.microsoft.com/bmg 

This is a bit rough on the edges, and takes quite a few test-runs before you find out what is going on, but it is in fact quite clever, though the only method I could find to make my install _not_ to appear as failed, was to set the Default exit code to "Success" while this as default by the BMG is set to "Fail".

When you reach this far, your bootstrapper package is nicely listed when you wish to configure your publishing by ClickOnce, and - when done - the name of your font installer is listed at the published Publish page along with the other prerequisites.

/gustav


>>> Gustav at cactus.dk 10-10-2008 19:21 >>>
Hi all

How many of you are using this feature of Visual Studio?

I'm about finishing a major Windows app and decided to try the ClickOnce route. I've seen the demos and was a bit sceptical - but for no reason. 

This is sooo clever! Initial install at the workstations is a snap any user can handle and, really, deployment of a new version is not much more than a click to send the revised version to an FTP server or network drive and the user will automatically be offered to download and install the new version at a click of a button. 
Even a simple web page which you can e-mail a link to to potential users is created by the wizard.

/gustav





More information about the dba-VB mailing list