Deployment with IExpress: How to turn your MSI file into an EXE
I have no problem with MSI file downloads. They are as simple as running an EXE. However, for reasons unknown, a lot of people don’t seem to like or understand downloading and running an MSI file; they feel more comfortable with EXEs. Visual Studio Setup projects turn your application into an MSI and a
setup.exe file, which is inconvenient for distribution as generally online we want to provide the user with a single file download. Luckily there is a simple and free solution at hand in the guise of a quirky and little-known application included even as late as the Windows 7 base distribution called IExpress. This tool was originally created to enable branded deployments of Internet Explorer 6 (shocking, I know), but we can subvert it quite easily to our needs.
On the first build, we’ll need to create a SED file which defines how IExpress will perform the build. Bring up a command prompt or press START+R, type IExpress and press Enter to get the ball rolling.
Choose the following options on the next screens:
- Create new Self Extraction Directive file
- Extract files and run an installation command
- Enter the friendly name of your application on the ‘Package title’ screen
- No prompt (on Confirmation prompt screen)
- Do not display a license (this is unnecessary as the MSI installer will display your license agreement already)
- On the ‘Packaged files’ screen, click Add and choose only the MSI file created from your Visual Studio Setup project. Click Next.
- On the ‘Install Program to Launch’ screen, leave the Post Install Command blank and enter the following as the Install Program:
msiexec /i NameOfYourSetupFile.msi
- Choose ‘Default (recommended)’ on the ‘Show window’ screen
- Choose ‘No message’ on the ‘Finished message’ screen
- Enter a fileame for your target EXE, leave ‘Hide File Extracting Progress Animation from User’ unticked, but tick ‘Store files using Long File Name inside Package’ so that your filenames don’t get corrupted. You will get a warning when you tick this – click Yes to ignore it. You should set the target path for your EXE into the Release (or Debug) folder of your Visual Studio Setup project, ie. the same folder where the MSI file is created by Visual Studio.
- Choose ‘No restart’ (once again your MSI will prompt the user to do this if needed)
- Now save your SED file into the same folder as your Visual Studio Setup project (where your .vdproj file is located). It’s crucial you don’t save it into the Debug or Release sub-folders as the SED will get deleted without prompting when you re-build the Setup project if you do this.
- The package will now build. Check that it works.
For bonus points, we want to automate this when building the Setup project.
- Right click on the Setup project node in Visual Studio and choose Properties.
- Change the
PostBuildEventproperty as follows:
iexpress /N /Q NameOfSedFile.SED
- Change the
RunPostBuildEventproperty to On successful build. This will ensure that IExpress only runs when the Setup project build completed without errors.
And there you have it. Building your Setup project in Visual Studio should now produce a single EXE file at the end of the build which you can deploy on your web site or other distribution media!