From MSI to WiX, Part 1 - Required properties, by Alex Shevchuk
Following content is directly reprinted from From MSI to WiX, Part 1 - Required properties
Author: Alex Shevchuk
Introduction
Today I will start a series of posts about creating an MSI installation package using WiX. The goal here is to show what is omitted from the WiX documentation and explain not just what needs to be done in WiX, but also - why. In this series I will be using WiX 2.0, unless stated otherwise.
Because I will use tools from Windows Installer SDK, such as Orca, we need to install the Windows Installer SDK which is part of Microsoft Plafrom SDK. You can install it from here.
You can disable everything except Core SDK and Windows Installer SDK.
Creating WiX source file
Every WiX source file must have the following root element:
<?xml version='1.0' encoding='UTF-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
. . .
</Wix>
The extension of the WiX source file is usually wxs.
Defining required properties
Windows Installer is using five properties from the Property table in order to distinguish installed applications from each other.
Here is the list of required properties:
- ProductCode - Unique identifier for particular product release (GUID).
- ProductVersion - Version of the product. The format of this string is: major.minor.build.
- ProductLanguage - Numeric language identifier (LANGID) installer will use for any strings in the user interface that are not authored in the database. This value must be one of the languages listed in the Template Summaryproperty in the Summary Information stream.
- ProductName - The name of the application.
- Manufacturer - The name of the manufacturer of the product.
It is highly recommended to add the UpgradeCode property to support future upgrades to the product.
Tip: Always remember that letters in GUIDs in the Windows Installer are always upper-case. If you are using Visual Studio to edit your WiX source code, here are instructions on how to create a Visual Studio macro to automate the process of creating a new GUID.
Here is how we add required properties to the WiX source file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi"> <Product Id="{1EFFDCD2-4B4B-439E-8296-651795EE02D9}"
Name="Minimal Windows Installer Sample"
Language="1033"
Codepage="1252"
Version="1.0.0"
Manufacturer="Acme Corporation"
UpgradeCode="{15F9543C-1C8D-45D6-B587-86E65F914F20}"> </Product>
</Wix>
This is how properties correspond to attributes of the <Product> element:
- ProductCode - Id.
- ProductVersion - Version.
- ProductLanguage - Language.
- ProductName - Name.
- Manufacturer - Manufacturer.
- UpgradeCode - UpgradeCode.
Now, we need to add the last required property which is stored in the Revision Number Summary property of theSummary Information stream. This property is the package code of the installer package. Summary Information stream has a number of additional properties and represented in the WiX source file by <Package> element.
Summary Information stream properties and their counterparts in <Package> element
| Property | Attribute | Description |
|---|---|---|
| Revision Number | Id | Package Code |
| Subject | Description | For installation package the value of this field is the product name and can have the same value as ProductName property: [ProductName] |
| Comments | Comments | Describes the general purpose of the installation package. Usually contains the following message: This installer database contains the logic and data required to install [ProductName]. |
| Author | Manufacturer | Manufacturer of the installation package. Usually has this value: [Manufacturer] |
| Codepage | SummaryCodepage | Numeric value of the ANSI code page used for any strings that are stored in the summary information. |
| Keywords | Keywords | List of keywords. For installation packages should include "Installer" as well as other product-specific keywords. |
| Template | Platforms Languages |
Indicates the platform and language versions that are compatible with this installation database. The valid syntax for the Template property is:
platform;langId,langId,... Wix is using two separate properties for platform and the list of languages. |
| Page Count | InstallerVersion | Minimum installer version required. |
| Word Count Bit 0 |
ShortNames | Original source is using short/long file names. |
| Word Count Bit 1 |
Compressed | Default compression status for all files in the installation package. |
| Word Count Bit 2 |
AdminImage | Source is original media/administrative image created by an administrative installation. |
| Word Count Bit 3 |
InstallPrivileges | Elevated privileges can be/are not required to install this package. |
| Security | ReadOnly | Conveys whether the package should be opened as read-only. |
| Title | Type of the installer package. For installation package the value of this field usually: Installation Database |
|
| Character Count | Used in Transforms only. | |
| Creating Application | Application created the installer database. | |
| Last Saved By | In an installation package, the installer sets this property to the value of theLogonUser property during an administrative installation. This property should be set to Null in a final shipping database. | |
| Last Save Time/Date | The last time when this installation package was modified. | |
| Create Time/Date | The time and date when an author created the installation package. | |
| Last Printed | In an installation package, the Last Printed Summary property can be set to the date and time during an administrative installtion to record when the administrative image was created. For non-administrative installations, this property is the same as the Create Time/Date Summary property. |
Here is how our updated source file looks like after adding <Package> element:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{1EFFDCD2-4B4B-439E-8296-651795EE02D9}"
Name="Minimal Windows Installer Sample"
Language="1033"
Codepage="1252"
Version="1.0.0"
Manufacturer="Acme Corporation"
UpgradeCode="{15F9543C-1C8D-45D6-B587-86E65F914F20}">
<Package Id="{909A6CE7-2739-4522-92C2-03AD7D7EE4CD}"
Description="Minimal Windows Installer Sample"
Comments="This installer database contains the logic and data required to install Minimal Windows Installer Sample."
InstallerVersion="200"
Languages="1033"
SummaryCodepage="1252"
Platforms="Intel"
ReadOnly="no"
Compressed="yes"
AdminImage="no"
Keywords="Installer"
ShortNames ="no"
Manufacturer="Acme Corporation" />
</Product>
</Wix>
Package code is represented by the Id attribute and must be unique for every package.
Important: Languages attribute must contain in its list the language ID from the Language attribute of the <Product> element.
More about properties
Windows Installer properties are the variables that you can use to define the behavior and actions taken by Windows Installer:
- The names of the properties are case-sensitive.
- A public property name must be all in uppercase, whereas a name of private property must have at least one lower case letter in its name. Only public properties can be specified in the command line.
- Public properties can be restricted by using SecureCustomProperties property. This property contains the semicolon delimited list of restricted properties.
Specifying directory layout for the product
In MSI database the Directory table specifies the directory layout for the product. Directory layout starts with the mandatory root directory represented by the TARGETDIR property. Default value for the TARGETDIR property is the value of the SourceDir property.
The directory layout is represented in WiX by the hierarchy of <Directory> elements.
Here is the directory layout for our installation project.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Minimal" LongName="MinimalInstallation"> </Directory>
</Directory>
</Directory>
I am using standard Program Files folder as an installation folder for our sample application. Inside that folder I am creating a subfolder with the short name (the one which is using MS-DOS 8.3 name pattern) "Minimal" and the long name for that folder "MinimalInstallation". Windows Installer has a set of predefined names for Windows System folders which you can use in your installation projects.
Now we add the feature we will install with our sample product and component which is a part of that feature.
The definition of the logical tree structure of features is defined in the Feature table of MSI database. In WiX we are using <Feature> elements.
Tip: Level column in the Feature table (Level attribute of the <Feature> element) holds the initial installation level of the feature. An install level of zero disables the feature and prevents it from being displayed. Users can use the INSTALLLEVEL public property to control features to be installed from the command line.
Components are listed in the Component table of MSI database and in WiX represented by <Component> elements. For this sample our component won't install anything. Here is how our WiX source file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{1EFFDCD2-4B4B-439E-8296-651795EE02D9}"
Name="Minimal Windows Installer Sample"
Language="1033"
Codepage="1252"
Version="1.0.0"
Manufacturer="Acme Corporation"
UpgradeCode="{15F9543C-1C8D-45D6-B587-86E65F914F20}">
<Package Id="{909A6CE7-2739-4522-92C2-03AD7D7EE4CD}"
Description="Minimal Windows Installer Sample"
Comments="This installer database contains the logic and data required to install Minimal Windows Installer Sample."
InstallerVersion="200"
Languages="1033"
SummaryCodepage="1252"
Platforms="Intel"
ReadOnly="no"
Compressed="yes"
AdminImage="no"
Keywords="Installer"
ShortNames ="no"
Manufacturer="Acme Corporation" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Minimal" LongName="MinimalInstallation">
<Component Id="Component1"
Guid="{78E22868-B750-47EB-9E4C-C19CCA939394}">
<CreateFolder />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="Feature1"
Title="Feature1 title"
Description="Feature1 description"
Level="1"
ConfigurableDirectory="INSTALLDIR" >
<ComponentRef Id="Component1" />
</Feature>
</Product>
</Wix>
Notice that <Component> element has a child node <CreateFolder>. We need that because Windows Installer will not create an empty folder by default. In order to create an empty folder, the name of the folder must be presented in theCreateFolder table in MSI database.
Tip: If your installation creates an empty subfolder and it is not present after installation is done, that's because you forgot to add <CreateFolder> element.
You can build our Minimal sample application by using these commands:
candle.exe Minimal.wxs
light.exe -out Minimal.msi Minimal.wixobj
or, if you prefer MSBuild (Minimal.proj):
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Required by WiX -->
<!-- Path and name of the output without extension -->
<OutputName>Minimal</OutputName>
<!-- What need to be built -->
<OutputType Condition="$(OutputType)==''">package</OutputType> <!-- The path to the WiX installation -->
<ToolPath>d:\WIX\</ToolPath> <!-- Input path to source files.
If not passed, assumes the same folder where project file is located. -->
<BaseInputPath Condition="$(BaseInputPath)==''">$(MSBuildProjectDirectory)\</BaseInputPath> <!-- Create a compiled output in the folder where project is located -->
<OutputPath Condition="$(OutputPath)==''">$(MSBuildProjectDirectory)\</OutputPath> <!-- Add missing trailing slash in paths -->
<ToolPath Condition="!HasTrailingSlash('$(ToolPath)') ">$(ToolPath)\</ToolPath>
<BaseInputPath Condition="!HasTrailingSlash('$(BaseInputPath)') ">$(BaseInputPath)\</BaseInputPath>
<OutputPath Condition="!HasTrailingSlash('$(OutputPath)') ">$(OutputPath)\</OutputPath>
</PropertyGroup> <!-- Candle.exe command-line options -->
<ItemGroup>
</ItemGroup> <!-- Light.exe command-line options -->
<ItemGroup>
</ItemGroup> <Import Project="$(ToolPath)wix.targets"/> <!-- List of files to compile -->
<ItemGroup>
<Compile Include="$(BaseInputPath)Minimal.wxs"/>
</ItemGroup>
</Project>
here is the command to use this file for compilation:
msbuild Minimal.proj
Now, if you've installed the Installer SDK, you can right-click on Minimal.msi file and select "Edit with Orca" menu item. This will bring the Orca application with Minimal.msi database loaded. Select "Tools" menu and then "Validate..." submenu. Uncheck the "Show "INFO" Messages" check box and click the "Go" button. This will start the package validation. In our case validation will trigger the ICE71 warning: "The Media table has no entries." Basically, it means that every package must have a record in the Media table with DiskId equal 1. We can fix it by addind <Media>element to our WiX file right before first <Directory> element:
<Media Id="1" />
<Directory Id="TARGETDIR" Name="SourceDir">
Tip: Always run ICE validation on your installation packages.
Now you can install the Minimal.msi and see that it does create the Minimal subfolder in the Program Files folder and delete it on uninstall.
The reason why we were using public property INSTALLDIR in the line:
<Directory Id="INSTALLDIR" Name="Minimal" LongName="MinimalInstallation">
is because we want to give our users ability to change the installation directory in the command line during installation of our product. Try to install Minimal.msi using the following command:
msiexec /i Minimal.msi INSTALLDIR=c:\MinimalTest
As you can see, now our msi creates a MinimalTest folder in the C driver root instead of in the Program Files.
What's next
Next time we will add an Add/Remove Program support to our package.
From MSI to WiX, Part 1 - Required properties, by Alex Shevchuk的更多相关文章
- From MSI to WiX, Part 2 - ARP support, by Alex Shevchuk
Following content is directly reprinted from From MSI to WiX, Part 2 - ARP support Author: Alex Shev ...
- From MSI to WiX, Part 8 - Major Upgrade, by Alex Shevchuk
Following content is reprinted from here, please go to the original website for more information. Au ...
- From MSI to WiX, Part 4 - Features and Components by Alex Shevchuk
Following content is directly reprinted from : http://blogs.technet.com/b/alexshev/archive/2008/08/2 ...
- Wix: Using Patch Creation Properties - Minor Update
Based on the project created in Wix: Using Patch Creation Properties - Small Update, Following chang ...
- Wix: Using Patch Creation Properties - Small Update
Source Reference: wix help document -- WiX Toolset License Using Patch Creation Properties A patch ...
- Wix学习整理(3)——关于Windows Installer和MSI
原文:Wix学习整理(3)--关于Windows Installer和MSI 关于Windows Installer Windows Installer是微软Windows操作系统自带的一个软件安装和 ...
- WIX Custom Action (immediate, deffered, rollback)
Following content is directly reprinted from From MSI to WiX, Part 19 - The Art of Custom Action, Pa ...
- Spring properties dependency checking
In Spring,you can use dependency checking feature to make sure the required properties have been set ...
- COM Error Code(HRESULT)部分摘录
Return value/code Description 0x00030200 STG_S_CONVERTED The underlying file was converted to compou ...
随机推荐
- centos 火狐浏览器安装adobe flash player插件
来个CentOS 6.3 为Firefox安装Flash插件教程 下载install_flash_player_11_linux.i386.tar.gz打包文件到本地 终端进入install_fl ...
- UVA 705 Slash Maze
Slash Maze By filling a rectangle with slashes (/) and backslashes ( ), you can generate nice litt ...
- MFC 学习之 鼠标移动到Toolbar按钮上显示提示信息(tooltip),状态栏也随之改变
1.在ResourceView里加入Toolbar资源,命名IDR_TOOLBAR1 2.在主程序的.h文件中加入变量: CToolBar m_toolbar;CImageList ...
- ios 说一说UINavigationController 的堆栈
iOS的界面堆栈管理比android的要好用很多. 这里写两点:一点是 如何重回前面的vc,而不是push一个alloc的新界面.第二点就是判断当前堆栈显示的vc是何vc. vc堆栈: vc1-> ...
- 多边形背景生成工具推荐-Trianglify
前端开发whqet,csdn,王海庆,whqet,前端开发专家 low poly低多边形(相似于折纸的效果),多边形风格的设计应用越来越多,今天我们就来看一个利用d3.js写成的生成器Triangli ...
- (收藏)sokcet编程
C# Socket网络编程精华篇 C#编写高性能网络服务器(源码) .net自动更新组件Ant 客户端服务器通信demo(附源码) 有了WCF,Socket是否已人老珠黄? Socket服务器整体架构 ...
- iOS 符号表恢复 & 逆向支付宝
推荐序 本文介绍了恢复符号表的技巧,并且利用该技巧实现了在 Xcode 中对目标程序下符号断点调试,该技巧可以显著地减少逆向分析时间.在文章的最后,作者以支付宝为例,展示出通过在 UIAlertVie ...
- php笔记01:php基本语法格式
1. <?php ....... ?> 2. <script laugnage="php"> ....... </script> 3. < ...
- Forwarding a Range of Ports in VirtualBox
STAN SCHWERTLY MAY 9, 2012 ARTICLES 3 COMMENTS Doesn't allow forwarding a range of ports through the ...
- 关于python使用list出现乱码的解决
昨天在敲python的一个小实例的时候,用到了readlines()这个函数,但是将文件读出来的时候是乱码,也并不是完全乱码,只是中文出现了乱码,数字还是显示正常的,同时也不报错.源码以及文件截图如下 ...