Click here to Skip to main content
12,764,163 members (39,708 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked
Posted 31 Jul 2013

MSI wrapper for any installer using Wix

, 1 Aug 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
MSI wrapper for any installer using Wix.

Last time we make windows installer package using MakeMsi compiler. Now we will make same using Wix. Wix is XML based setup compiler for Windows Installer format. We will make simplest as possible setup package wrapping existing installer, InnoSetup for example. First we need make directory tree, required element is TARGETDIR directory.

<Directory Id='TARGETDIR' Name='SourceDir'>
Inside we will describe temporary folder for wrapped package:
<!-- temp folder -->
<Directory Id='TempFolder'>
   <Component Id='my_setup' 
        <File Id="mysetup_exe" Source="mysetup.exe" /> 

Component is required element to describe File entry, and it should be referred in Feature.

<Feature Id="MainApplication" Title="Main Application" Level="1">
    <ComponentRef Id="my_setup" />

For choose destination folder for wrapped package we will describe Directory inside Program Files folder.

<!-- PF folder -->
    <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLLOCATION" Name="MyApp" />

To assign this directory from Windows Installer dialogs we will describe Property.

<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" ></Property>

For show dialog we need to use special feature of Wix. It will use simple dialogs sequence including destination folder path.

<UIRef Id="WixUI_InstallDir" />

We will need to describe base properties of our setup package, it should be the root of XML tree.

<?xml version='1.0'?>
<Wix xmlns='<a href="'">'</a>>

Well, anything is looks good, but by default resulting setup package will show License agreement with Common Public License by default. If your package no need to show license agreement, you have to use some trick, adding folowing code:

  <UIRef Id="WixUI_InstallDir" />
  <!-- skip licence dialog -->
  <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" 
    Value="InstallDirDlg" Order="2">1</Publish>
  <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" 
    Value="WelcomeDlg" Order="2">1</Publish>

And finally we will run wrapped package, describing custom action:

<CustomAction Id="run_setup" 
          ExeCommand="/SP- /SILENT /SUPPRESSMSGBOXES /LANG=English 
            /NOCANCEL /DIR=&quot;[INSTALLLOCATION]&quot;" 
          Return="check" />

Also need to add this custom action to setup sequence, run only if not installed:

   <Custom Action="run_setup" Sequence='5401'>NOT Installed</Custom>



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ernest Poletaev
Software Developer (Senior) Enterprise Information Systems, Plc
Thailand Thailand
Senior Software Developer in Enterprise Information Systems, an ERP / CRM / Docflow Software Solution Provider for Russian Local Market.

Professional Developer (C, C++, C#), since 1984. Experienced in many programming technologies.

Now i resides in Kalasin, Thailand, working remotely for my company

You may also be interested in...


Comments and Discussions

QuestionUninstall, upgrades, and more... Pin
Jacob Reinholdt30-Oct-13 5:58
memberJacob Reinholdt30-Oct-13 5:58 
QuestionFull source code download link is broken Pin
Member 103107392-Oct-13 2:09
memberMember 103107392-Oct-13 2:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 1 Aug 2013
Article Copyright 2013 by Ernest Poletaev
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid