« Zip up a Folder with .NET 4.5 and Visual Studio 2012 | Main | Interlude: 2012-08-11 »

How to Easily create an MSI to install your PowerShell modules  

Recently I decided I wanted my VisioPS PowerShell module to be installed into the users Powershell module folder. This would make it easy to use VisioPS because the module could always be imported from any PowerShell instance without having to change directories, etc.

Naturally I wanted an real MSI installer for it. Unfortunately Visual Studio 2012 No longer supports setup projects and InstallShield does support Visual Studio 2012 yet. So, I decided to create my own using WIX.

I started with the description here: http://sev17.com/2010/11/building-a-powershell-module-installer/ –  which is a bit out-of-date and more complex than I needed. I transformed those instructions into a simple powershell script that will build an MSI.

The script is too long to go into detail here, but an excerpt should illustrate its usage.

At the topic of the script are “user inputs”. Simply replace these values as needed and run the script. It will take the contents of a folder ($binpath) and create an MSI for you. If $binpath contains a file called “license.rtf” that file will be shown as the license in the MSI.

Here's an example from the script I use to build the VisioPS installer.

$productname = "Visio Powershell Module"
$productshortname = "VisioPS"
$productversion = ""
$manufacturer = "Saveen Reddy"
$helplink = "http://visioautomation.codeplex.com"
$aboutlink = "http://visioAutomation.codeplex.com"
$binpath = "D:\saveenr\code\visioautomation\VisioAutomation_2010\VisioPS\bin\Debug"
$productid = "4A2B528A-93E5-431D-97BB-79767C7677C5"
$upgradecode = "EE659AB6-BE76-426E-B971-35DF3907F9D4"
$upgradeid = "F14DC5AF-1234-498A-9646-AA27E03957AA"
$delete_temp_folder_on_exit = $true;
$output_msi_file = join-path ([Environment]::GetFolderPath("MyDocuments")) ($productshortname + ".msi")

You can find the code here on my SkyDrive: click here

Ultimately I hope to use a newer version of InstallShield, but this was a nice learning exercise.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (2)

Hi. I want to be one of the cool kids, but the link to your script is dead. It sounds like exactly what I need (something simple for PowerShell modules).

If if it is not too much trouble, could you repost?

thanks much!

April 26, 2014 | Unregistered CommenterJP

@JP - thanks for pointing that out. I've fixed the link. Please let me know if it doesn't work for you.

April 28, 2014 | Registered Commentersaveenr

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>