Creating custom “Prerequisites” for installation

If you have ever installed any software in your machine, you know what I am talking about. A textbook meaning of Prerequisite is

“A thing required as a prior condition for something else to happen”

It case of software it usually means that to run some piece of software it need to have something else present already, it can be either another software or a hardware. For any application developed in .NET has first prerequisite is … to have .NET framework already installed on that machine !! And if you have created any installer for your application then you know that this prerequisite is automatically handled by installer itself but what if your application has special requirement of its own, that needs to be satisfied to make application work properly ? At first glance it looks like that you have to write some sort of funny code to handle this situation … but it is not entirely true. Writing some kind of code and include it in your installer via dll is one way to do that but there is more easy and a bit forgotten solution available …which requires less effort compared to first option …. it is Bootstrap Manifest Generator for Visual Studio 2008, despite of its age, this piece of application still works very well for VS2010 .. and I hope that it will work with VS.next as well.

This software creates a manifest file for a any software that you want to use as a prerequisite and then you can use this manifest file to include that item in your installer’s prerequisite list. For this post … say I have an application which requires to have Firefox web browser already installed on a machine where I will be installing my application ! Now in real life it will be very very strange requirement for any application, but just bare with me this one Smile … ok ? Just like any good application installer, I will want to include setup of Firefox with my main MSI and if Firefox doesn’t exist on a machine then have it run before main installation starts. Available prerequisites for an application can be selected by going into Installation Project Property –> Prerequisites –> and then select what ever you want to have as a prerequisite … say .NET framework, Windows Installer, VC++ runtimes etc. But here you will see that Firefox doesn’t exist as an option to include as prerequisite. This is when Bootstrap Manifest Generator (from now on I will just call it BMG) comes in play. And in rest of post I will show how BMG can be used to add custom prerequisites for your installation project.

manifest_generator_1 manifest_generator_2_5

Once you download BMG from above link, install and run it. UI itself looks pretty lame but but believe me it does the job … and does it very well. Ok, so click on new project, it will show you two option .. package manifest or msbuild. We are interested in preparing manifest so select “package manifest”. And then it will open a manifest editor screen. First is to name the package project, I named it as “Firefox”.

manifest_generator_2 manifest_generator_3

Then add an application by clicking on installer icon. This will popup application installer setting page. There just select your location of installer and it might be helpful to include URL for original download location (if you have any). So once installation exe is added just build the project and if it successfully builds one then it will show you message with location of manifest file.

Now copy all contents of this manifest project and copy them to “C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages”  or “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages” if you using 64bit machine. v7.0A is for VS2010 so this will cause our custom prerequisite to appear as an option in installation project of VS2010. Same can be done for VS2008 by adding it to v6.0A folder.

manifest_generator_4 manifest_generator_5

Once that is done just go to prerequisite option of your windows installation project and voila … now you have a Firefox browser in prerequisite options !! Now, if you want to keep your installation smaller than just select “download prerequisites from the component vendor’s website” option in installation location for prerequisite. But to make it work you had to add homesite URL while preparing manifest file in BMG (its just suggestion, I am feeling very lazy to try it out whether it works or not).

manifest_generator_6 manifest_generator_7 manifest_generator_8

Once done with adding prerequisite just build the project and you should see new folder “Firefox” in installation directory. Now to make sure that this pre-requisite gets installed first you will need to run setup using setup.exe NOT USING .MSI.

And this concludes this tutorial for how BMG can be used to add custom prerequisites for your installation project

It’s Just A Thought … Peace

Gaurang Sign

Leave a Reply

Your email address will not be published. Required fields are marked *