Monday, April 2, 2012

Creating a Wix Windows Service installer project template for Visual Studio 11

When I wrote my first blog post about creating a wix web service installer I promised I would look into how to make a Visual Studio project template out of it.
I won't do that today. I will start out simple and create a project template for making windows service projects with Wix and Visual Studio 11.
Creating Wix Windows Service installers using the standard Wix Setup Project template isn't exactly rocket science, but you still need to remember what XML you have to put into your Product.wxs file.
I am not the kind of guy who can remember these things and I hate having to google around for such things when I just want to quickly make a very basic installer for my Windows Service. Most of the time I just want an installer that installs the thing, with no options or anything, but I am required to have an installer. As long as I can produce a MSI file that installs it, everyone is happy.

So I want a project template that lets me say, I want my installer, and preferably that's it. I haven't got quite there yet, but I have a template that lets me say, I want my installer, and then it will ask me to fill in the '*' marked fields, which I think is a lot easier than the generic Wix Setup Project template that gives me no hint as to what I need to do to make a Windows Service Installer.

Creating a Visual Studio Project Template

First you should download and install Visual Studio 11 beta SDK.
Microsoft provides pretty good description on how to How to: Create Project Templates and then Creating Extensions By Using the VSIX Project Template, the latter doesn't seem to be 100% accurate at the moment, but I guess that is as expected considering it is a beta version.

I started out creating a setup project using the Wix 3.6 Setup Project template. This creates a project containing mainly a Product.wxs file.
I changed this to a generic Product.wxs file that will create a Windows Service Installer once the required fields has been filled in (the fields marked in yellow starting with <*Insert>):


When the project is as we want it, we export it as a template by going to the file menu and select "Export template..."
Export Template Wizard

Select "Project template" and the project you want to use for your template.
You will now get a zip file in %USERPROFILE%\My Documents\Visual Studio 11\My Exported Templates\

This zip file can then be used when we create our vsix file.

Add new project and select a VSIX project.

Then you will be presented with the following dialog which should be filled in something like this:

Then switch to Assets tab and add the zip file you built earlier.
Then hit build and you have your vsix file.

This vsix can then be uploaded to visual studio gallery if you want, I have uploaded mine here:

The promised template for Web Service installers will follow soon....

No comments:

Post a Comment