How to create a .wxi file for a library (or dependency)

wixl allows a wxs installer to describe package dependencies. Let say your project uses the Opus library, and it needs to ship its runtime in the installer. Your project can include a wxi file with the preprocessing directive <?include opus.wxi ?>, or using the wixl-only <?require opus.wxi?> (to avoid multiple inclusions).

However, writing a wxi file can be tedious if the library has many files, or if your project has many dependencies. (wixl already ships many wxi files, although they could be shipped with the libraries)

To help writing wxi files, you can use the wixl-heat tool. It takes a list of files as an input, and a prefix path:

$ echo /bin/foo.dll | wixl-heat -p / 
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Directory Id="dir9A5D56716D566997FA290054D161AF96" Name="bin">
        <Component Id="cmp4870EAD46CE134BD907939200EAA1FF7" Guid="*">
          <File Id="filBE6F14A070D5EAA77634DCAF71913D56" KeyPath="yes" Source="SourceDir/bin/foo.dll"/>
        </Component>
        </Directory>
    </DirectoryRef>
  </Fragment>
<!-- generated with msitools 0.93.40-6aec -->
<!-- wixl-heat -p / -->

To change the location for your sources (ex change for 32 bits or 64 bits build), it is recommended to use a SourceDir variable, which you can define with the wxil-heat argument --var var.SourceDir

In Fedora, there are already MinGW packages, it's a good idea to generate wxi files with the help of rpm. The runtime files have to be filtered, either manually (in post-edition), or using some grep commands, as in the example below.

For convenience, with the wixl .wxi provided files, the destination directory is not TARGETDIR, but INSTALLDIR (which can be defined as the package prefix, for example ProgramFiles\MyProject in the main wxs file)

Finally, it is usually a good idea to reference the dependencies by components, so one can specify the component group for Opus (following wixl .wxi convention using CG. prefix) --component-group CG.opus

$ rpm -ql mingw32-opus | grep -v /usr/i686-w64-mingw32/sys-root/mingw/include/  | grep -v /usr/i686-w64-mingw32/sys-root/mingw/lib | grep -v aclocal | wixl-heat --var var.SourceDir -p /usr/i686-w64-mingw32/sys-root/mingw/ --component-group CG.opus --directory-ref INSTALLDIR
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="INSTALLDIR">
      <Directory Id="dir9A5D56716D566997FA290054D161AF96" Name="bin">
        <Component Id="cmp6D8DA1D65E275B9306E5F9FAE5C31A4B" Guid="*">
          <File Id="filE4C8F8EC8AFAEA7CFF7B005FBEAD30DF" KeyPath="yes" Source="$(var.SourceDir)/bin/libopus-0.dll"/>
        </Component>
        </Directory>
    </DirectoryRef>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="CG.opus">
      <ComponentRef Id="cmp6D8DA1D65E275B9306E5F9FAE5C31A4B"/>
    </ComponentGroup>
  </Fragment>
</Wix>
<!-- generated with msitools 0.93.40-6aec -->
<!-- wixl-heat -var var.SourceDir -p /usr/i686-w64-mingw32/sys-root/mingw/ -component-group CG.opus -->

To make the package win64-aware, you can pass --win64 to wixl-heat command

msitools/HowTo/CreateLibraryWxi (last edited 2014-11-04 15:05:44 by FabianoFidencio)