2009年3月10日火曜日

Windows Install XML详细教程

wix介绍(1)
什么是wix?
Windows Installer XML(wix)平台是一套工具和规范,协助你轻松创建MSI和MSM类型的安装包。wix工具集可以模拟传统的编译和链接,从源代码创建可执行的安装包。对于wix,源代码就是XML格式的文件。这些文件经schema(wix.xsd)验证后,通过预处理、编译、连接来创建安装包。通过wix平台,可以很容易地从一套短的源代码创建多个Windows Installer安装包。

Windows Installer XML 概述 (2)

Windows Installer XML, 或者wix, 提供一个描述Windows Installer database (MSI or MSM)的模式, 以及将XML描述文档转化成安装包的一套工具包。第二版的模式(wix.xsd) 增加额外的内容, 使得由一套XML文档创建多个Windows Installer安装包更加容易。wix工具集可以模拟传统的编译和链接,从源代码创建可执行的安装包。

本文介绍如何使用工具包编译和链接wix源代码来生成Windows Installer安装包。

注:本文假设你知道Windows Installer安装包的格式。

.wxs & .wixobj – Windows Installer Xml Files

在一个Windows Installer XML系统中,所有源文件的扩展名都是 .wxs 。就如同 .cpp 之于 C++ 或者.cs 之于 C#。.wxs 文件经过预处理和编译生成扩展名为.wixobj的文件。当所有源文件编译成.wixobj文件后,就可以链接这些 .wixobj文件生成Windows Installer安装包。

.wxs 文件结构

所有的 .wxs文件都是XML格式的文档,以作为根节点。 在预处理之前,文档的其余部分可能匹配 WiX schema,也可能不匹配。不管怎样,预处理之后,所有源文件必须符合WiX schema的要求,否则编译通不过。根元素 最多只能包含 , 其中的一个作为子元素。包含 的个数不受限制。当源文件编译生成.wixobj文件后,这3个子元素产生了3个新的节元素。因此,这三个子元素常常称为节元素。

需要特别注意的是,每个源文件只能有一个 或者 节元素,这是因为他们将被编译生成称作入口节的特殊节元素。入口节是链接处理的起始点。有关节,入口节和全部的链接处理会在后面作详细描述。

节元素的子元素定义了Windows Installer安装包的内容。 对应Property表, 对应Directory表。
大多数元素包含"ID"属性,该属性将作为Windows Installer文件行的主键。 注意,WiX schema的第一版中,主键以元素的文本表示。由于一些原因,该方式并非合适,已经改为"ID"属性。大多数情况下,当源文件编译生成.wixobj文件后,"ID"属性用来确定了一个标记号。

Symbols and references

.wixobj文件中的每一个标记号由元素名加"ID"属性的唯一码组成。标记号非常重要,因为他们可以被其他任何源文件中节元素作为引用对象。例如, 可以包含在一个源文件的里,包含在另一个源文件的里。在下,通过添加创建一个显性的引用对象,直接引用第一个文件中定义的标记号。链接程序负责将标记号和引用链接。某些情况下,编译程序在处理源文件时会产生隐性引用。隐性引用具有与显性引用相同的行为。

除了上面提到的简单引用,WiX还支持复杂引用。复杂引用是在链接程序必须生成额外的信息来链接标记号和引用时使用。复杂引用最好的例子是 Windows Installer中Feature/Component的关系。当通过显性引用时,链接程序必须读取的标记号和的标记号,然后在FeatureComponents表中增加一个入口。

Feature/Component的关系甚至可以更复杂。因为中的某些元素,比如,包含指向与Component关联的Feature的引用。这种来自子元素的引用,被称作反向引用,有时也称作feature backlinks。复杂引用和反向引用的处理,可能是链接程序必须实现的最难的工作。

注意,标记号的定义和引用是WiX工具包第二版的新内容。之前的做法是必须将Components打包成Merge Modules,然后用merge进行标记号链接。新的系统在定义标记号方面更加灵活,避免了为确保每个Merge Module唯一的过多开销。

Windows Installer XML 概述 (3)

Structure of the .wixobj file

编译程序为每个源文件生成相应的.wixobj文件, .wixobj文件是XML格式的文档,遵照WiX项目中objects.xsd schema的定义。.wixobj文件包含一个或多个节,每个节包含标记号和指向其他标记号的引用。

虽然标记号和引用是.wixobj文件中最重要的数据,但他们只是信息中很少的一部分。大多数.wixobj文件的主要内由, and 组成,这些元素提供了Windows Installer安装包的原始数据。许多情况下,链接程序不但处理标记号和引用,还要使用和更新.wixobj中的原始数据。

但有趣的是,.wixobj文件schema (objects.xsd)使用了camel外壳,而源文件schema (wix.xsd)使用了Pascal外壳。这种选择明确表示.wixobj文件不能被用户编辑。事实上,对于只能用Wix工具包处理的数据,用来定义这些数据的schema都使用了camel外壳。

candle - Windows Installer XML Compiler

candle.exe是Windows Installer XM的编译程序,candle.exe的任务是将作为输入的.wxs源文件预处理生成有效的符合WiX schema( wix.xsd )的XML文档。然后,每一个经后处理的源文件被编译成.wixobj文件。

编辑过程是比较简单的。WiX schema遵从简单的递归降序解析。编译程序处理每个单元,依次为.wixobj文件创建新新的标记号,计算必要的引用和生成原始数据。

第二版candle.exe与第一版基本相同。仅有的变更包括:使新的标记号和引用可以链接以及基于客户反馈的改变。两个版本不同的地方包括:新的.wixobj文件的格式由MSI改为XML格式,主键的创建放在了链接时间,二进制文件的导入放在了链接时间。

light - Windows Installer XML Linker

light.exe是Windows Installer XM的链接程序。light的任务是处理一个或多个.wixobj文件,从多个外部文件中提取元数据,创建Windows Installer安装包(MSI or MSM)。必要时,light还将创建.cab文件和嵌入到Windows Installer安装包的数据流。

链接程序开始搜索从命令行输入的.wixobj文件以找到入口节。若发现一个以上的入口节,light返回错误。错误返回是必要的,因为入口节定义了准备创建什么类型的Windows Installer安装包,MSI () 或者 MSM ()。 不可能从一个链接操作创建出两个安装包。

当链接程序确定入口节时,将定义在每个.wixobj文件中的标记号储存在标记号表中。当找到入口节后,链接程序通过寻找标记号表中的所有标记号试图处理该节中的所有引用。当发现标记号在不同的节中,链接程序递归连处理新节中的标记号。这个过程要搜索必要的节以解决引用的全部嵌套,直到所有的引用都满足为止。如果一个标记号在所有提供的.wixobj文件都没有找到,链接程序退出处理,并返回一个错误表示未定义的标记号。

所有的节找到之后,将处理复杂引用和反向引用。这个过程出现在以下场合:Components 和 Merge Modules 准备挂接其上一级的 Features,或者准备添加Merge Modules, Components到ModuleComponents表中。反向引用处理是为象Shortcut, Class, 和 TypeLib这类元素添加合适的Feature ID。

一旦所有的引用解决后,链接程序处理所有的行,检索引用文件的语言、版本号和hash值,计算媒体布局,以及包括一些必要的标准流程,以确保成功安装顺序。这部分的处理,结束前通常生成附加的行,以获得额外的与入口节的联系,来确保它们被打包到最终的Windows Installer安装包。

最后,light产生IDT文件,并将他们导入到Windows Installer安装包。 数据库创建完成后,最后一步是合并Merge Modules,如果需要,创建.cab文件。输出结果是一个完整功能的Windows Installer安装包。

WiX Help - Authoring (1)

Authoring是撰写WiX源文件来创建Windows Installer安装包的过程。WiX源文件的扩展名通常为.wxs,是XML格式的文档,格式必须符合WiX schema的要求。(可以在 wix.xsd 找到)

WiX Help - Authoring (2)

WiX可以创建的Windows Installer数据库类型包括:Windows Installer 安装包 (MSI 文件)和 Merge Modules (MSM 文件)。

编写第一个 .wxs File

选择一个你最喜欢的XML编辑器,来编写全部范例。我使用notepad,创建一个新文件“product.wxs”。虽然取什么文件名都无所谓,但.wxs扩展名可以让我们知道这是一个Windows Installer Xml源文件。现在,让我们添加只有3行代码的.wxs文件:





这构成源文件的轮廓。你可以把这个空文件作为candle.exe的输入,来输出一个空的object文件。按照下面的步骤,你可以看到非常简单的输出:

C:\test> candle product.wxs
Microsoft (R) Windows Installer Xml Compiler version 1.0.1220.15022
Copyright (C) Microsoft Corporation 2003. All rights reserved


C:\test> type product.wixobj
xmlns="http://schemas.microsoft.com/wix/2003/04/objects"
src="C:\test\product.wxs" />

C:\test>

在继续往下之前,先注意两件事情。
(1)当没有任何错误时,除了文件头,candle不输出其他文本。事实上,你可以在命令行中指定-nologo来抑制文件头的输出。这种情况下,candle不输出任何信息,除非有错误产生。
(2)源文件的路径被储存在.wixobj文件中。这有助于追踪错误的来源。事实上,当错误产生时,链接程序使用"src"属性输出更多信息的错误消息。

现在我们已经看到了一个空的源文件产生了一个空的object文件。让我们创建一个可安装的Windows Installer安装包。添加下面的代码到你的product.wxs文件:



Version='1.0.0.0' Manufacturer='Microsoft Corporation' UpgradeCode='12345678-1234-1234-1234-123456789013' >
Description='My first Windows Installer package'
Comments='This is my first attempt at creating a Windows Installer database'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />











这可以让我们创建一个MSI文件,该文件的ProductCode是 {12345678-1234-1234-1234-123456789012},ProductLanguage 是"1033",ProductVersion是"1.0.0.0"。所有这些信息都取自元素。元素定义了所有加入到MSI的摘要信息。最后的树与一起创建。这可以让我们的MSI在机器上注册成功。

按照下面的步骤,让我们编译,链接,安装,并看一下已经注册的文件包。

注意:MSI需要管理员权限,如果不是以管理员权限安装,将退出而无错误提示。

C:\test> candle product.wxs
Microsoft (R) Windows Installer Xml Compiler version 1.0.1220.15022
Copyright (C) Microsoft Corporation 2003. All rights reserved

product.wxs

C:\test> light product.wixobj
Microsoft (R) Windows Installer Xml Linker version 1.0.1220.15022
Copyright (C) Microsoft Corporation 2003. All rights reserved

C:\test> msiexec /i product.msi

C:\test> \\delivery\tools\msiconfig.exe
.
.
.
{12345678-1234-1234-1234-123456789012} Test Package
.
.
.

在列出的所有你的机器上已经安装的Windows Installer包中,你应该看到"Test Package"。你也可以到Control Panel中的Add/Remove Programs,"Test Package"已经出现在那里。再把它卸载掉。

现在我们已经有了一个可以正确安装和卸载的包。让我们真正安装一些东西。创建一个名为"readme.txt"的文本文件,随便输入一些文本。"Hello, World!"是最讨人喜欢的。接下来,要修改product.wxs:



Version='1.0.0.0' Manufacturer='Microsoft Corporation' UpgradeCode='12345678-1234-1234-1234-123456789013'>
Description='My first Windows Installer package'
Comments='This is my first attempt at creating a Windows Installer database'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />



















编译,链接,然后安装那个 MSI后,你应该可以看到在你系统的"Program Files"下有个目录名叫"Test Program"。在那个"Test Program"下应该有你创建的"readme.txt"文件以及你输入的文字。最后别忘了卸载这个MSI,以便将来重新安装。

相信与否,这就是创建Windows Installer安装包的全部过程。


WiX Help - Authoring (3)

创建Merge Modules
创建Merge Module与创建Windows Installer package非常相似。让我们先创建一个名为"module.wxs"的文本文件。如下输入标准的框架:




然后创建Merge Module,我们添加元素以及所需的属性:




Comments='This is my first attempt at creating a Windows Installer Merge Module'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />




编译和链接这个代码。你将得到一个非常小的.msm文件。让我象前面给Windows Installer package添加代码一样,给Merge Module添加一个文本文件。首先创建一个名为"readme2.txt"的文本文件,并输入一些不同的文字。然后,更新源码来包含这个文件:




Comments='This is my first attempt at creating a Windows Installer Merge Module'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />











现在,你有了一个Merge Module,它可以和其他团队共享来安装你的"readme2.txt"文件。让我们在Windows Installer package实际应用它。

将Merge Module合成到一个 .wxs 文件

Merge Modules只能合并到Windows Installer package。幸运的是,我们有了一个.wxs 文件用来创建Windows Installer package。因此让我们添加2行代码(是的,只有2行)来合并你的新模块。打开"product.wxs",添加:



Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
Comments='This is my first attempt at creating a Windows Installer database'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />






















现在当你编译"product.wxs",它将包含来自Merge Module的安装逻辑和文件。当你再次安装"product.msi"时,你应该在"Test Program"目录下看到两个文本文件。

WiX Help - Authoring (4)

Adding Custom Actions

你已经熟悉了创建Windows Installer安装包的基本方法,让我们进入下一阶段来添加用户自定义功能。Windows Installer XM的每一个发行版都包含一套WiX Server CustomActions,因此我们将用他们来创建范例。现在打来 wix\bin\ca 目录,拷贝 "sca*.dll" 到 "product.wxs"的目录下。

不同于将CustomAction库文件拷贝到源文件目录下,让我们先练习编写一个名为"sca.wxs"的小模块来定义CustomActions。添加可以直接读取CustomActions Server表和调度不同行为的CustomAction。




Return='check'/>
Return='check'/>





这段代码可以编译,但不可以链接。记住,链接需要有一个入口节,而不是一个入口节。我们需要与一个包含的源文件来链接该文件。在正确处理链接问题之前,先让我们添加其他的CustomActions,这些 CustomActions与已经添加的直接CustomActions一样重要。




Return='check'/>
Return='check'/>

Return='check'/>

DllEntry='StartMetabaseTransaction' Execute='deferred' Return='check'/>
DllEntry='RollbackMetabaseTransaction' Execute='rollback' Return='check'/>
DllEntry='CommitMetabaseTransaction' Execute='commit' Return='check'/>

DllEntry='CreateMetabaseKey' Execute='deferred' Return='check'/>
DllEntry='DeleteMetabaseKey' Execute='deferred' Return='check'/>
DllEntry='CreateAspApp' Execute='deferred' Return='check'/>
DllEntry='WriteMetabaseValue' Execute='deferred' Return='check'/>
DllEntry='WriteMetabaseMultiString' Execute='deferred' Return='check'/>
DllEntry='DeleteMetabaseMultiString' Execute='deferred' Return='check'/>

DllEntry='CreateDatabase' Execute='deferred' Return='check'/>
DllEntry='DropDatabase' Execute='deferred' Return='check'/>
DllEntry='ExecuteSqlStrings' Execute='deferred' Return='check'/>
DllEntry='ExecuteSqlStrings' Execute='rollback' Return='check'/>






好了。我们已经完成了"sca.wxs"的编辑。我们已经成功定义了全部的针对WiX Server CustomActions的入口点。那么,怎样在product.wxs中添加代码来调用WiX Server CustomActions?让我们添加一段测试代码来调用CustomAction以在安装过程中产生一个错误。这就是"ErrorOut" CustomAction。




Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
Description='My first Windows Installer package'
Comments='This is my first attempt at creating a Windows Installer database'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />


























这3行就是调用"ErrorOut" CustomAction所需要的全部代码。现在用light.exe来链接两个文件。以下是编译,链接和安装的步骤。

C:\test> candle product.wxs module.wxs sca.wxs
Microsoft (R) Windows Installer Xml Compiler version 1.0.1256.19889
Copyright (C) Microsoft Corporation 2003. All rights reserved.

product.wxs
module.wxs
sca.wxs

C:\test> light module.wixobj
Microsoft (R) Windows Installer Xml Linker version 1.0.1256.19889
Copyright (C) Microsoft Corporation 2003. All rights reserved.

C:\test> light product.wixobj sca.wixobj ut product.msi
Microsoft (R) Windows Installer Xml Linker version 1.0.1220.15022
Copyright (C) Microsoft Corporation 2003. All rights reserved

C:\test> msiexec /i product.msi

当MSI开始回滚安装时,没有任何警告。记着,当安装完文件之后,"ErrorOut" CustomAction被调用,迫使安装失败。MSI于是删除已安装的文件并悄无声息地退出。对于有兴趣的读者,可以添加成功和失败的对话框作为练习。

翻译 Msi Tables to WiX Schema

对于WiX schema,并非总是明显地对应于Windows Installer schema。下面是一些有关二者之间关系的帮助信息。

DuplicateFile Table
对应于File节点内的CopyFile节点。你只需设置Id, DestinationFolder, 和 DestinationName的属性值。

LaunchCondition Table
对应于Fragment 或 Product下的Condition节点。你只需设置Message的属性值。

LockPermissions Table
对应于Permission。

MoveFile Table
对应于Component下的CopyFile节点。你需要腰设置除了Delete之外的所有属性值。设置Delete为'yes'是为了使用msidbMoveFileOptionsMove选项。

PublishComponent Table
对应于Category。这里有一个范例说明如何在MSI中实现PublishComponent。

MSI
ComponentId Qualifier Component_ AppData Feature_
{11111111-2222-3333-4444-5555555555555} 1033 MyComponent Random Data MyFeature

WiX

Qualifier='1033'/>

.
.
.






RemoveIniFile
对应于IniFile。仅需要设置Action的属性值为'removeLine' 或 'removeTag'。

RemoveRegistry Table
对应于Registry。仅需要设置Action的属性值为'remove' 或 'removeKey'。

Windows Installer XML Standard CustomActions

WiX 工具包提供一些CustomActions用来负责配置资源,如IIS(Internet Information Services)网站和虚拟路径,SQL Server数据库和scripts,用户帐号,文件共享等。这些CustomActions由两个.wixlibs库提供,sca.wixlib 和 wixca.wixlib。前者包含了"Server CustomActions",而后者提供更多通用的安装CustomActions。将来,这来两个库有可能合并,但现在由于历史原因,他们是分开的。

sca.wixlib - Server CustomActions

Internet Information Services (IIS) CustomAction - 创建和配置网站、虚拟目录、Web应用等。
SQL Server CustomAction - 创造数据库和执行的SQL脚本和报表。
FileShare CustomAction - 创造和配置文件共享(SMB).
Performance Counter CustomAction - 安装和卸载性能计数器。

wixca.wixlib - General CustomActions

Secure Objects CustomAction - 标准的LockPermission标没有提供的安全对象。(ACLs) 详情见中的Extended属性。
Service Configuration CustomAction - 配置ServiceInstall表没有提供的Windows Service属性。
Quiet Execution CustomAction - 运行不显示窗口的控制台应用程序。
XmlFile CustomAction - 允许你配置XML文件作为安装包的一部份,详情见

新的CustomActions一直在开发中。我们的目标是建立一个标准的满足任何需求的CustomActions。如果你有任何CustomAction需求,请告诉我们。


Using the Server Custom Actions

wix 工具包包括了一个用户定制的库。该库的核心是对服务器的用户化设置。服务器定制扩展了MSI可安装网站、共享文件和用户帐号等的整套资源。这些定制正确建立组件和资源的关联,遵照所有规则来正确安装、卸载和回滚相关联的部分组件的安装或者卸载。本文将举例概述这些应用。

本文假设读者已经理解MSI用户定制的类型,并已经阅读了"WiX Overview" 和 "Writing in WiX"。

Server Custom Action building blocks

scasched.dll, scaexec.dll 和 sca.wixlib随wix工具包一起发布。这两个DLL文件导出服务器定制功能所需的全部接口。当你创建一个使用服务器定制功能的MSI安装包时,他们在MSI的Binary表的结尾。sca.wixlib包含一系列wix fragments,你可以通过链接来确保所有的错误消息、定制记录以及二进制文件记录被链接到你最终的MSI中。

将服务器定制功能加入到MSI中的最简单的方法,是拷贝sca.wixlib和两个DLL(scasched.dll and scaexec.dll)到你的编译环境的路径下。该路径在哪并不重要,重要的是wixlib和两个DLL在同一路径下。当你用light.exe链接 MSI时,你只需在要链接的wixobjs 和 wixlibs列表中包含sca.wixlib的全路径。

Basic Example
首先让我们做一个练习,当MSI安装时创建一个用户帐号。
















这个简单范例将在目标机上创建一个新的用户,名为"testName1",密码为"pa$$word"。为了编译这个NSI,首先将代码拷贝到文件中,记着将"PUT-GUID-HERE"更换成实际的GUID,然后运行"candle.exe yourfile.wxs"编译,运行'light.exe yourfile.msi yourfile.wixout sca.wixlib'链接(sca.wixlib前加全路径)。现在用Orca打开生成的msi文件,查看Error表和Binary表,你会发现所有用户管理的数据都被连接到了MSI中。这之所以会产生,是因为你已经完成了两件关键的事。首先你在下使用了元素,这意味着一个用户将作为MSI的一部分被安装。其次,你连接了sca.wixlib,编译器确保在 sca.wixlib中的一系列fragments中,只有与wxs中使用元素关联的数据才被连接到MSI中。

The server custom action elements

在上面的例子中,你学习了通过在WiX中使用,与sca.wixlib连接后,错误消息和binary表的数据就自动添加完成。当你使用如这样的特定元素时,WiX编译器支持自动引用sca.wixlib中的对应的元素。如前所述,服务器定制增加了安装许多新类型资源的功能。每一个资源类型有一个或多个元素允许和MSI一起被安装。如果你使用sca.wixlib,你唯一需要知道的是与你想安装资源相符的符号。下面列出了一些服务器定制支持的资源类型和控制其安装的元素。

Web Sites -
Web Applications -
Certificates -
SQL databases -
SQL scripts -
SQL strings -
Users -
FileShares -
Perfmon Counter registration -

通过在你的wix文件中使用表中的合适元素以及链接sca.wixlib,你可以正确使用wix server custom actions。

Performance Counter CustomActions

PerfCounter元素能够让你利用Windows API注册自己的性能计数器。这里有几个部分一起使用来完成注册:

Your performance DLL -
DLL必须输出Open, Collect, 和 Close 方法。更多细节请参考MSDN。

Performance registry values -
注册表必须包含键值指向你的DLL及其Open, Collect, and Close方法。这些键值由Registry元素创建。

Perfmon INI and H text files -
这些文件包含显示于界面的文字描述。更多细节请参考MSDN。

The RegisterPerfmon custom action -
你可以链接sca.wixlib来确保在MSI中包含定制功能。定制功能调用(Un)LoadPerfCounterTextStrings来注册你的计数器。为了调用自定义功能,在Perfmon.INI文件 File元素里创建PerfCounter元素。PerfCounter元素包含唯一一个属性:Name,Name属性应该与注册表、WIX源文件 fragment节和PerfCounter.ini文件中的名称匹配。

























--------------------------------------------------------------------------------

Sample PerfCounters.ini:
[info]
drivername=MyApplication
symbolfile=PerfCounters.h

[languages]
009=English
004=Chinese

[objects]
PERF_OBJECT_1_009_NAME=Performance object name
PERF_OBJECT_1_004_NAME=Performance object name in Chinese

[text]
OBJECT_1_009_NAME=Name of the device
OBJECT_1_009_HELP=Displays performance statistics of the device
OBJECT_1_004_NAME=Name of the device in Chinese
OBJECT_1_004_HELP=Displays performance statistics of the device in Chinese

DEVICE_COUNTER_1_009_NAME=Name of first counter
DEVICE_COUNTER_1_009_HELP=Displays the current value of the first counter
DEVICE_COUNTER_1_004_NAME=Name of the first counter in Chinese
DEVICE_COUNTER_1_004_HELP=Displays the value of the first counter in Chinese

DEVICE_COUNTER_2_009_NAME=Name of the second counter
DEVICE_COUNTER_2_009_HELP=Displays the current rate of the second counter
DEVICE_COUNTER_2_004_NAME=Name of the second counter in Chinese
DEVICE_COUNTER_2_004_HELP=Displays the rate of the second counter in Chinese

PERF_OBJECT_1_009_NAME=Name of the third counter
PERF_OBJECT_1_009_HELP=Displays the current rate of the third counter
PERF_OBJECT_1_004_NAME=Name of the third counter in Chinese
PERF_OBJECT_1_004_HELP=Displays the rate of the third counter in Chinese
Sample PerfCounters.h:
#define OBJECT_1 0
#define DEVICE_COUNTER_1 2
#define DEVICE_COUNTER_2 4
#define PERF_OBJECT_1 8

Quiet Execution CustomAction

Quiet Execution CustomAction,即wixca.dll中的QtExec自定义动作,他可以执行命令行。

Immediate execution



.
.
.




这将导致及时执行命令行。如果命令行的退出码出错(非0),由于Return值设为"check",将导致安装失败。如果你不想引起安装失败,可以修改该值为"ignore"。(还会记录日志)

如果你想及时运行多条命令行,在执行每一个命令行之前,你需要多次派配QtExec以及设置QtExecCmdLine的属性值。

Deferred execution
你也可以通过设置自定义动作的data属性来延期运行命令行。如果代码以及时模式运行,它将试图执行 QtExecCmdLine的value,如果代码以延期模式运行,它将试图执行custom action data的value。custom action data是与custom action同名的属性。下面是一个延期执行命令行的例子:




.
.
.




Extensions

WiX支持以下3类扩展。

介绍
预处理扩展(Preprocessor Extensions)允许客户编译之前修改源文件。
编译器扩展(Compiler Extensions)允许客户在文件被编译成二进制之前将已编辑的XML编译成内表格式。
打包扩展(Binder Extensions)允许客户提供图象处理和数据生成的交错能力。

通过这些扩展,可以扩展WiX的功能以支持自定义处理、XML语法编译或者为一些特殊生成要求的流程创建语义环境。

一般要求
虽然从源代码开始是如何使用每一类扩展的最好方法,但是他们有一些东西是通用的。
1. 必须在与WiX其他部分相同的.NET 1.1环境下实现。
2. 构造一个合适扩展对象的子类并给他起一个容易区分的名字。
3. 构建一个合适语法的schema来提供对可能之处的检查验证。
4. 构造内表定义并用编译器注册他们。
5. 为可扩展的方法和虚拟成员构造overrides。
6. 创建扩展为一个DLL。
7. 将扩展DLL与WiX EXEs放在一起。
8. 通过WiX编译器的命令行注册。


注意事项
在购买一个扩展之前,应该先评估一下该外部工具及其包含的语法是否能够提供满足你的技术需求灵活性。多重扩展和扩展类型可以被支持,但不能保证特殊类型的扩展被处理的顺序。因此,在同一个扩展类中,扩展之间不应存在次序依赖关系。

Using the WixUI dialog library

WixUI对话框库包含一套"stock"多话框,用来提供wizard风格的安装用户界面。用一个UIRef为安装包添加一个界面。WixUI可以自定义,比如在界面上显示图片或者添加、删除某个界面。

Note: WixUI 对话框库现在还处在技术评估期。请在WiX-devs邮件列表上提供使用回馈。WixUI对话框库是否有用?你有其他建议吗?需要其他界面吗?基于回馈的信息,WixUI库可能有一些非兼容的改变。


使用WixUI对话框组件库

WixUI对话框组件支持4种通用对话框序列:

1. WixUI_Mondo
包括整套对话框:welcome, license agreement, setup type (typical, custom, and complete), feature customization, directory browse, 和 disk cost。也包括Maintenance-mode对话框。当产品的某些特性在默认情况下不安装,或者典型安装和完全安装有很大不同时,使用 WixUI_Mondo。
Note:当用户选择Typical 或 Complete安装选项时,WixUI_Mondo使用SetInstallLevel控制事件来设置安装等级。对于Typical,安装级别设为 3,Complete设为100。feature和安装级别的详情,请参见INSTALLLEVEL 属性。

2. WixUI_FeatureTree
是WixUI_Mondo的简单版本。它去掉了setup type对话框。用户直接从许可协议界面进入feature customization界面。当默认情况下安装全部特性时,WixUI_FeatureTree比WixUI_Mondo更合适。

3. WixUI_InstallDir
不允许用户选择features, 但允许选择安装路径。
Note: 要使用WixUI_InstallDir,你必须为WIXUI_INSTALLDIR设置一个值,该值由Directory的Id确定,作为初始的安装路径。例如:




...



...



4. WixUI_Minimal
最简单的WixUI组件类型。唯一的界面组合了welcome 和 license-agreement对话框,去掉了feature customization对话框。当产品没有可选特性时,WixUI_Minimal是合适的。


如何为安装包添加WixUI界面

假设你有一个现成的安装包,功能具备但没有界面。你应该遵循下面的步骤来使用WixUI对话框。

1. 在你的安装源代码中添加一个UIRef元素,使用上面对话框套件的一种作为Id的属性值。例如:





为light命令行添加wixui.wixlib和适当的WixUI本地化文件名。例如:

light Mondo.wixobj %WIXUI_PATH%\WixUI.wixlib -loc %WIXUI_PATH%\WixUI_en-us.wxl -out Mondo.msi

请参见doc/examples/wixui 路径下的.wxs文件。

2. 指定许可文件

WixUI界面组件中有一个界面显示最终用户的许可协议。要指定你的产品许可协议,需要在运行light之前包含一个License.rtf文件在当前目录下。如果没有该文件,light将使用ui路径下的License.rtf文件。

3. 使用翻译过的错误和进度文字

默认情况下,WixUI 不包含任何翻译过的错误和进度文字。你可以通过引用WixUI_ErrorProgressText UI元素来包含他们。




4. 自定义对话框组件

通过拷贝、修改已有组件,你可以很容易地从WixUI组件中添加、删除对话框。
范例请参见doc/examples/wixui/custom路径下的工程。下表描述了该工程文件:

CustomDialogSet.build
NAnt build文件,用于创建自定义对话框组件。如果需要,创建WixUI通用对话框元素,然后build CustomDialogSet.wxs 和 CustomDlg.wxs来生成CustomDialogSet.wixlib。

CustomDialogSet.wxs
自定义对话框组件定义文件。拷贝WixUI_FeatureTree组建,并在WelcomeDlg初始化完成之后添加CustomDlg对话框。

CustomDlg.wxs
简单的自定义对话框。

TestCustom.wxs
WiX源代码,调用自定义的CustomDialogSet.wixlib库。

5. 更换图像
WixUI对话框库包含的图片用于welcome、installation-complete界面背景和其他界面的banner。你可以重载这些图片,以使用自己商标的目的。为了更换图片,需要在WiX源文件Bitmaps子目录下添加以下图片文件。

bannrbmp.bmp
顶端banner 493 × 58

dlgbmp.bmp
welcome 和 install-complete 对话框的背景图片 493 × 312

exclamic.ico
wait-for-costing对话框的Exclamation图标 32 × 32

info.ico
cancel 和 error对话框的Information图标 32 × 32

New.ico
directory-browse 对话框的Button图标 16 × 16

Up.ico
directory-browse 对话框的Button图标 16 × 16

19 件のコメント:

匿名 さんのコメント...

Ιt's a pity you don't havе a donate button! I'd certainly donate to this excellent blog! I guess for now i'll settle for bοoκmarking and аdԁing youг RЅЅ feеd to mу Goοgle accοunt.

I loοk fоrward tο fresh updateѕ
and will talk аbout thіѕ site wіth my Facebοok gгоup.
Chat ѕoοn!
Here is my webpage ; Chemietoilette

匿名 さんのコメント...

Great post. I used to bе сheсking
conѕtantly this blog and I am imρressed!
Extremely useful info particulaгly the closіng part :)
I tаke cагe of such іnfοrmation a lot.
I used to bе seеkіng this particulaг info for a long time.

Thanks and beѕt of luck.
Feel free to visit my web-site ; http://f.ar.ae/search.php/All/DSC00731

匿名 さんのコメント...

Τurn on a flourеd surface and knead for 10 minutes, аԁding more
flour as needed. All you have tο do
in ordеr to obtain these coupons is to go to the internet and search for the оnе that ѕuits уоu needs then just print them.
I don't like pizza sauces, so I opt to use two cans of diced tomatoes as the first layer-one can of plain and the other of Italian.
My web blog - http://loan46noah.blog.fc2.com

匿名 さんのコメント...

I'm impressed, I must say. Seldom do I come across a blog that's equally educative and
entertaining, and without a doubt, you've hit the nail on the head. The problem is something which not enough folks are speaking intelligently about. I'm very happy that I found this
in my hunt for something regarding this.

My webpage ... Http://Www.mashro3Na.com/

匿名 さんのコメント...

It's really a great and useful piece of information. I am happy that you shared this useful info with us. Please stay us informed like this. Thanks for sharing.

Feel free to surf to my homepage: Chemietoilette
My website: Chemietoilette

匿名 さんのコメント...

No matter if sоme onе sеarсhes fοг his
required thing, thus he/ѕhe needs to be avaіlable thаt in
detail, therefore that thing is maintaіned оver here.


Feel free to visit my weblog; augenoperation

匿名 さんのコメント...

With hаvin so much content and artiсles do
you evег run іnto аny іsѕueѕ оf plаgоrism οr
сopyгight vіolatiоn?
My website has a lot of completely unique сontent ӏ've either created myself or outsourced but it looks like a lot of it is popping it up all over the web without my permission. Do you know any ways to help prevent content from being ripped off? I'd
cегtаіnlу appгесіate іt.


Негe is my ρage: Chemietoilette
My website: www.supercaniegatti.it

匿名 さんのコメント...

anаlyѕt I sensе that therе
аre nοn-rationаl foгceѕ
at operаte. Masonry heaters consіst
οf а tiny fіreplаce boх designeԁ to
ratio with the ѕmokе chamber prevіouslу
mentiοned. A entіre graіn breakfаst οf outdated-fashionеԁ οatmeal wіth almonԁѕ (grind them uρ tο hidе them, if
іmρortant) wіll keеp a κiԁ way more tіme thаn orangе
juice аnԁ a bagel.

Αlѕo viѕit my wеb sіte: blog.bitcomet.com
Also see my page > pizza stone for grill instructions

匿名 さんのコメント...

Saved аs a favоrite, I like your blog!


Fееl fгee tο visit my weblog .
.. Chemietoilette

匿名 さんのコメント...

Ι likе thе valuable info you ρrovide in yοur articleѕ.
Ι will bookmark уour blog аnd check аgain here regularly.
I'm quite certain I will learn a lot of new stuff right here! Best of luck for the next!

Look at my web blog ... augenoperation

匿名 さんのコメント...

It's remarkable designed for me to have a web site, which is good in support of my know-how. thanks admin

Here is my blog: http://www.mylinkvault.com/beach5ton/page-1.htm

匿名 さんのコメント...

Hi Dear, aгe уоu in fact viѕiting thiѕ web sitе dailу, if so afteг that you will defіnitely
take nice know-hoω.

Heгe is my blog post :: http://tasteitaly.mytweetb2b.com/

匿名 さんのコメント...

It's an remarkable post in favor of all the online users; they will take advantage from it I am sure.

Feel free to surf to my weblog :: Chemietoilette

匿名 さんのコメント...

Its a chef's expression for 'a sitе fоr eѵеrуthіng аnd the ωhole lot
іn іts plасe'. - Centre tunnel chimney duct to maximise economical warm airflow. They have lived life akin to that of really good saints, sages and Rishis who ended up well-known for their penance and austerities.

Feel free to visit my web page ... http://bootrolf90.blog.com/2013/01/16/blodgett-pizza-oven-a-possible-owners-guide-to-baking-ideal-pizzas-every-time

匿名 さんのコメント...

When an individuаl ԁеcidеѕ
to make the trаnsitiοn from eating meat to being a true
vegаn, many οf thе uѕual thіngs theу once enjoyeԁ go out thе
winԁow. Cook the chicken firѕt in
а little olive oil - cut the chicken into little cubes.
Τhey сan uѕe qualitу pгоduce
to make simple and great flavors.

Here is mу blоg post ... http://www.versicherungs-wiki.de/index.php?title=Benutzer:JulianeBr

匿名 さんのコメント...

This blog was... how do I say it? Relevant!! Finally I've found something that helped me. Kudos!

Here is my site :: Kindergeburtstag Mannheim

匿名 さんのコメント...

Hello, i read your blog from time to time and i
own a similar one and i was just curious if you get a lot of spam
responses? If so how do you protect against it,
any plugin or anything you can advise? I get so much lately it's driving me mad so any assistance is very much appreciated.

Also visit my homepage: Mannheim Kindergeburtstag

匿名 さんのコメント...

Excellent pieces. Keep writing such kind of information on your
blog. Im really impressed by your blog.
Hey there, You have performed an excellent job.

I will certainly digg it and personally suggest to my friends.
I'm sure they will be benefited from this site.

Take a look at my web blog: insidepastorkevinshead.blogspot.com

Alina Vlad さんのコメント...

I had a tubal July 2012 and have not felt the same since. I have horrible PMS for the entire week prior to my period, my cramping and bleeding is off the chart, migraines three times a week, hot flashes are starting. My doctor suggested getting an IUD...That was even worse DON'T DO IT!!! I have gained so much weight I weigh more than I was when I was pregnant last year. So I have been in search of weight loss and I did crossfit for 90 days with no results. Then a friend of mine introduced me to Dr Itua herbal center product and I was resistant at first but thought what the hell I will try it for 30 days. In 3 weeks time I have lost 8 pounds but the best part is some of my symptoms have gone away or are far less noticeable. I started my period three days ago and on day two I realized NO CRAMPING at all!!! Then I realized that the pms was not nearly as bad as it had been...There was no dull achy pain, no lower back pain, no deep depression, less tired. I just wanted to share this because I stumbled upon what seems to be a miracle. I will keep you posted as the months go on. I am so grateful and hope that everyone suffering can get the same relief I have found. Please email Dr Itua Herbal Center On drituaherbalcenter@gmail.com for more herbal remedy also he can cure Hiv/Aids, Herpes, Cancer, Parkinson, MS, Diabetes, Hepatitis, Fibroid, he can help with a remedy to get pregnant as well. if you want more info just contact him to share your health problems.