MSI2XML / XML2MSI
Usage of msi2xml
msi2xml [-q] [-n] [-m] [-e ENCODING] [-s [STYLESHEET]] [-b [DIR]] [-c [DIR[,MEDIACABS]] [-o XMLFILE] file
-q --quiet quiet processing
-n --no-sort disable sorting of rows
-m --merge-module convert a merge module (.msm)
-e --encoding=ENCODING force XML encoding to ENCODING (default is US-ASCII)
-s --stylesheet disable default XSL stylesheet
-s --stylesheet=NAME use XSL stylesheet NAME
-b --dump-streams=DIR save binary streams to DIR subdirectory
-c --extract-cabs=DIR,MEDIAS extract content of cabinet files of MEDIAS to DIR (see notes)
-o --output=FILE write MSI file to FILE
Note:
To allow for easier comparing, rows are sorted according to the first field's content. xml2msi will take up to 20 seconds to convert a .msi file if row sorting is enabled. To disable row sorting, and to speed up the conversion, add the -n option.
To convert a merge module, add the "-m" switch. This also sets the merge module attribute in the XML file to "yes", and xml2msi automatically reconstructs a merge module from it.
The -c / --extract-cabs option takes either no argument, a single argument or a comma-separated list of arguments:
No argument: all cabinet files listed in the Media table are extracted to the same directory as the output XML file;
A single argument (eg. --extract-cabs=cabs): all cabinet files listed in the Media table are extracted to the cabs sub-folder of the folder containing the output XML file;
Comma-separated list of arguments (eg: --extract-cabs=cabs,Cabs.1.cab,Cabs.2.cab): only the cabinet files "Cabs.1.cab" and "Cabs.2.cab" are extracted to the cabs sub-folder. Use a dot for the output folder to specify the default output folder: (eg: --extract-cabs=.,Cabs.1.cab,Cabs.2.cab)
Examples:
To convert a MSI file to XML use the following command:
msi2xml installation.msi
This creates the XML file "installation.xml" and the default stylesheet "msi.xsl".
To change the name of the generated XML file, use the -o option:
msi2xml -o outname.xml installation.msi
To extract all binary streams to external files and also decompress all cabinet files, use:
msi2xml -b streams -c files installation.msi
msi2xml -c OutputDir TestMSI.MSI
Usage of xml2msi
xml2msi [-m] [-p PREFIX] [-c [GUID]] [-d [GUID]] [-g [GUID]]
[-v VERSION] [-r [VERSION]] [-u [XMLFILE]] [-s "PROPERTY= VALUE"] [-o MSIFILE] XMLFILE
-q --quiet quiet processing
-m --ignore-md5 treat failed MD5 checks as warnings
-p --href-prefix=PREFIX prepend PREFIX to external references (href)
-c --package-code=GUID update package code (with GUID, see notes)
-d --product-code=GUID update product code (with GUID, see notes)
-g --upgrade-code=GUID update upgrade code (with GUID, see notes)
-v --product-version=VER update product version with VER (see notes)
-r --upgrade-version=VER update 'Upgrade' table entry 'VersionMax' (uses product version if VER omited, also see notes)
-u --update-xml=FILE write updated XML to FILE (or update input file if FILE omited)
-s --set="PROPERTY=VALUE" set/update PROPERTY in Property table to VALUE (repeat option for setting multiple properties)
-o --output=FILE write MSI file to FILE
Notes:
If the optional GUID argument is omitted, xml2msi creates a new GUID and uses it as the argument
The version arguments VER can either be an explicit version ("1.2.3.4") or the path (absolute or relative to current directory) to a file. Xml2msi will extract the file version of this file and use the result as the argument to the option.
Examples:
To build a MSI file from an XML file use the following command:
xml2msi installation.xml
This creates the MSI file "installation.msi".
If some of the MD5 checksum tests fail, due to changed binary files, specify the -m option to force the creation of the MSI file:
xml2msi -m installation.xml
The following command line is used to distribute a new version of the msi2xml package (notes in blue):
xml2msi --package-code ; stamps package code with a new GUID
--product-code ; stamps product code with a new GUID
--product-version=msi2xml.exe ; updates the product version with the file version of the file "msi2xml.exe"
--upgrade-version ; updates the VersionMax entry of Upgrade table to the new product version
--update-xml ; writes modifications back to input XML
msi2xml.xml ; input XML file (output is written to msi2xml.MSI)
xml2msi exportfile.xml
Anatomy of the XML file
The XML DOCTYPE is given in the next chapter. The following show the typical structure of a MSI-XML file:
<row>
<td>Field1</td>
<td dt:dt="bin.base64">Binary Encoded Data</td>
</row>
.
.
<row>
<td>Field1</td>
<td href="./bin/file" />
</row>
</table>
Notes:
-
The file starts with the XML processing instruction:
-
The database tags are enclosed by a
... tag pair.
2.1 The
2.2 You may optionally specify a codepage value using the "codepage" attribute.
2.3 Merge modules have the "msm" attribute set to "yes".
2.4 If you are using Base64-encoded binary data, the following namespace must be declared: xmlns:dt="urn:schemas-microsoft-com:datatypes"
2.5 The optional compression attribute specifies the algorithm used to compress files into cabinet files.
- A
... declares the Summary Stream Information (see MSI doc).
3.1 Each Summary Stream Information Property is declared in a tag pair carrying the property's name.
- The rest of the file consists of a series of
4.1 The table name is given by the "name" attribute of the
tag.- The table columns must be declared by a series of
5.1 The "key" attribute must be "yes" for primary key columns.
5.2 The column datatype must be declared in the "def" attribute. The syntax of the "def" attribute follows the Column Definition Format syntax, as specified in the MSI documentation.
5.3 Neither, the "key" and the "def" attribute are required for the standard database tables. xml2msi will use valid defaults if they are missing.
-
Each table record is enclosed in a
...
block. -
Each
...
block contains a series of field tags
7.2 The field content is specified between the
tags.7.3 White-space (including line breaks) are preserved.
7.4 The characters "&", "<" and ">" must be escaped as "&", "<" and ">".Alternatively, the data may be enclosed in a CDATA section:
All characters, except the sequence "]]" are allowed within a CDATA section.7.5 A NULL field is specified as
, or shorter:7.7 Instead of specifying the binary field content in the XML file, an external reference may be specified using the "href" attribute:
xml2msi validates the checksum for both, locally specified and external (href) field data..
7.1 The number of | fields must correspond to the number of declared columns ( | |||||
... |
7.6 Field content, especially binary data, may be encoded as Base64 MIME data. In this case, the attribute "dt:dt" must be specified as follows: | .... base64 encoded data .... |
Both, Internet URLs and local (relative & absolute) paths may be specified.
7.8 If you specify the special protocol "media:" in a href attribute of a binary field, xml2msi will build a cabinet file of the specified media and insert it on the fly. Example: href="media:Cabs.w1.cab" looks up the media "Cabs.w1.cab" in the media table and builds the cabinet before inserting it in the binary field. 7.9 An optional MD5 checksum may be included in the "md5" attribute: |