Click here to Skip to main content
15,891,473 members
Articles / Programming Languages / XML
Technical Blog

MSI wrapper for any installer using Wix

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
1 Aug 2013CPOL1 min read 15.3K   7   2
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.

XML
<Directory Id='TARGETDIR' Name='SourceDir'>
Inside we will describe temporary folder for wrapped package:
XML
<!-- temp folder -->
<Directory Id='TempFolder'>
   <Component Id='my_setup' 
        Guid='{YOUR-GUID-HERE-8148-2F82D9E7B4AE}'>
        <File Id="mysetup_exe" Source="mysetup.exe" /> 
   </Component>
</Directory>

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

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

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

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

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

XML
<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.

XML
<UIRef Id="WixUI_InstallDir" />

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

XML
<?xml version='1.0'?>
<Wix xmlns='<a href="http://schemas.microsoft.com/wix/2006/wi'">http://schemas.microsoft.com/wix/2006/wi'</a>>

<Product Id='{YOUR-GUID-HERE-A1BC-F3AB137A3E8A}' 
    Name='My Application' Language='1033' 
    Version='2.0.0.0' Manufacturer='My Company' 
    UpgradeCode='{YOUR-GUID-HERE-A1BC-F3AB137A3E8A}' >

    <Package InstallerVersion="300" Compressed="yes"/>
    <Media Id="1" Cabinet="myprog.cab" EmbedCab="yes" />

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:

XML
<UI>
  <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>
</UI>

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

XML
<CustomAction Id="run_setup" 
          FileKey="mysetup_exe"
          ExeCommand="/SP- /SILENT /SUPPRESSMSGBOXES /LANG=English 
            /NOCANCEL /DIR=&quot;[INSTALLLOCATION]&quot;" 
          Execute="deferred"
          Impersonate="no"
          Return="check" />

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

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

Download

License

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


Written By
Software Developer (Senior) i-BLADES
Thailand Thailand
I'm Android and Full Stack Software Engineer. 28 years in software industry, lots of finished projects. I’m never afraid of learning something new and you can see it by amount of skills in my resume.

I'm working remotely since 2009, self-motivated and self-organized.

There are no impossible projects. I have experience with Android, iOS, Web, Desktop, Embedded applications, VR, AR, XR, Computer vision, Neural networks, Games, IoT, you name it.

Comments and Discussions

 
QuestionUninstall, upgrades, and more... Pin
Jacob Reinholdt30-Oct-13 4:58
Jacob Reinholdt30-Oct-13 4:58 
QuestionFull source code download link is broken Pin
Member 103107392-Oct-13 1:09
Member 103107392-Oct-13 1: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.