This PowerShell script (vdproj2wix.ps1) is a very simple one for converting a Visual Studio setup project (aka a .vdproj file) into a WiX format one (i.e. a .wxs file). Although there are other more fully featured tools for creating a .wxs file, such as from an existing MSI binary, I wanted something that gave me a bare bones .wxs file that ignored all the boilerplate code that Visual Studio adds by default. As a server-side chappy all the MSI installers I create are simple ones designed to deploy a bunch of files into a folder - this script targets that scenario.
The script requires just a single argument to run - the path to the .vdproj file that you want to convert. It will create a new file in the same folder with the same name but with a .wxs extension instead, e.g.
C:\> PowerShell -File vdproj2wix.ps1 Path\To\MyProject.vdproj Input : Path\To\MyProject.vdproj Output: Path\To\MyProject.wxs
This should produce a simple .wxs file that looks something like the following:-
<?xml version="1.0"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="ABCDEFGH-ABCD-ABCD-ABCD-ABCDEFGHIJKL" Name="vdproj2wix Test" Language="1033" Version="1.0.0" Manufacturer="Chris Oldwood" UpgradeCode="ABCDEFGH-ABCD-ABCD-ABCD-ABCDEFGHIJKL"> <Package Compressed="yes"/> <Media Id="1" Cabinet="product.cab" EmbedCab="yes"/> <Directory Name="SourceDir" Id="TARGETDIR"> <Directory Name="ProgramFilesFolder" Id="ProgramFilesFolder"> <Directory Name="Chris Oldwood" Id="_1"> <Directory Name="vdproj2wix Test" Id="_2"> <Component Id="_1" Guid="F27BD5C5-A65D-4608-96D4-7C5DA1F76302"> <File Source="Example File.txt"/> <File Source="SubFolder\Another File.html" Name="Manual.html"/> </Component> </Directory> </Directory> </Directory> </Directory> <Feature Id="_1" Level="1"> <ComponentRef Id="_1"/> </Feature> </Product> </Wix>
NB: The WiX manual strongly advises you to put each file into a separate component to make servicing easier. While that may be the best approach for long-term maintenance I wanted the simplest .wxs file possible from the conversion. This is highlighted by the generation of "_N" style Id's where necessary.
As should be clear from the Introduction and example above this script is not intended to provide a hi-fidelity conversion, on the contrary it produces a basic .wxs file with entries for the following:-
Hence this means no UI stuff or any other fancy MSI features.
This script is freeware - you get what you pay for, nothing more, nothing less.
Please check the web site for updates.
31st October 2011