[Reference] Windows Installer XML (WiX) 3.0 Snippets

本文提供了一系列 Windows Installer XML (WiX) 3.0 的实用代码片段,帮助初学者解决安装包创建过程中的常见问题,涵盖了用户和服务账号定义、网站属性设置、虚拟目录配置、注册表项添加等多个方面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://blog.wharton.com.au/2007/06/windows-installer-xml-wix-30-snippets.html
Windows Installer XML (WiX) 3.0 Snippets

One of my tasks at DITR is the creation and refining of WiX packages. 

We are currently using Beta 3.0 which has proven to be quite a challenge as there are not many examples available to assist the novice WiX deployer (which I am). There are however heaps of v2.0 examples available that only need some minor modifications to make them work correctly under 3.0.

As I’ve spent a great deal of time researching and trialing different techniques, I thought I’d post some snippets to assist those looking for similar functionality. These snippets may not be 100% perfect, but they work and will give you a head start on using this great toolset.

To use these examples you must include the following namespace declarations in your WiX project:

<?xmlversion="1.0"encoding="UTF-8"?>>

<!—
Add the xmlns:iis attribute to allow access to WIX IIS functions (Requires WixIIsExtension reference)
Add the xmlns:util attribute to allow access to WIX util functions (Requires WixUtilExtension reference)
-->>

<Wixxmlns="http://schemas.microsoft.com/wix/2006/wi"
       xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
       xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
</Wix> >

There is also a bug in the IDE version of the WiX which does not persist the “Cultures” property (found on the Linker Tab of the Project Properties dialog) in the “.wixproj” file meaning that you will get an error when trying to use these namespaces. You need to open the “.wixproj” file for your project in notepad and set the “Cultures” attribute to “en-US” (or whatever culture you are using for your project) in both the ‘Debug’ and ‘Release’ nodes:

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
      <Cultures>en-US</Cultures>
</PropertyGroup> >

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
      <Cultures>en-US</Cultures>
</PropertyGroup> >

Define Default User/Service Account>

<!--
The Account Name ([SERVICEACCOUNT]), Password ([SERVICEACCOUNTPASSWORD]) and Domain/Server Name ([SERVICEDOMAINNAME]) are gathered via a custom dialog. >

We can then use this default account in any area of our WiX that requires a User    Account by referencing serviceAccount.
-->>

<util:UserId ='serviceAccount'Name='[SERVICEACCOUNT]'Password='[SERVICEACCOUNTPASSWORD]' Domain='[SERVICEDOMAINNAME]' ></util:User>
>

Define Default Web Site Properties>

<!-- Web site is only created if it doesn’t already exist -->>

<iis:WebSiteId='DefaultWebSite'Description='Default Web Site'>>

<iis:WebAddressId='AllUnassigned'Port='80' />>

</iis:WebSite>
>

Define Default Virtual Directory Properties>

>

<iis:WebDirPropertiesId='WebVirtualDirProperties'Execute='yes' Script='yes' Read='yes' WindowsAuthentication='no'>

AnonymousAccess='yes'AnonymousUser='serviceAccount' IIsControlledPassword='yes'/>
>

>

Create an Application Pool in IIS 6.0>

<ComponentId='C_MyAppPool'Guid='3C06911D-C31A-427E-8CA6-AEFC65161B1A' >>

      <iis:WebAppPoolId='MyAppPool'Name='MyAppPool'Identity='other'User='serviceAccount' >>

      </iis:WebAppPool>>

</Component>>


Create a Virtual Directory using Application Pool in Default Web Site>

>

<!--
TARGETVDIR is the name of the Virtual Directory for this site.
TARGETDIR is the directory location of the files for the site.
-->>

<PropertyId="TARGETVDIR"Value="AuthenticationWebService" />>

<ComponentId='C_VirtualDirComponent'Guid='{A598E09C-B770-4df2-BE08-E069A718B938}'>>

      <iis:WebVirtualDirId='VirtualDir'Alias='[TARGETVDIR]'Directory='TARGETDIR'>

WebSite='DefaultWebSite'DirProperties='WebVirtualDirProperties' >>

      <iis:WebApplicationId='WebApplication'Name='[TARGETVDIR]' WebAppPool='C_MyAppPool'/>>

      </iis:WebVirtualDir>>

</Component>
>

Update an XML Configuration File>

<!--
TARGETDIR is the directory location of the files for the site.
The SERVICEENDPOINT attribute below is used to match an input control on a EnterConfigurationValuesForm dialog box (which you need to define).                             >

Tip: The Value attribute below can be used as a command line arguement when running the MSI from the command line. For example:                              >

msiexec /i C:"ActivityAuditSetup.msi SERVICEENDPOINT=http://localhost:8005/TimeStampService/service /quiet
-->>

<ComponentId="C_ConfigFile"Guid="{8943581F-D07B-49f4-AF09-23541F7EB2F7}">>

   <util:XmlFileId='ModifyServiceEndPoint'Action='setValue' >

      ElementPath='/configuration/system.serviceModel/client/endpoint["[]@name="S113"["]]'>

      Name='address'File='[TARGETDIR]web.config'Value='http://[SERVICEENDPOINT]:8113/MyService/Service' />>

</Component>
>

>

Add a Registry Entry >

<ComponentId="C_EventLogReg"Guid="{05F254DE-E990-4FD6-86B7-11200B148B36}">>

   <RegistryKeyRoot="HKLM"Key="SYSTEM"ControlSet001"Services"Eventlog"Application"Wcf_S113" >

      Action="create" />>

   <RegistryValueRoot="HKLM"Key="SYSTEM"ControlSet001"Services"Eventlog"Application"Wcf_S113">

      Action="write"Name="EventMessageFile" Type="expandable">

      Value="C:"WINDOWS"Microsoft.NET"Framework"v2.0.50727"EventLogMessages.dll"/>>

 </Component>

Install a Windows Service>

>

<ComponentId="ProductComponent"Guid="{ED4F5E2A-D8B6-42e7-9330-9282AA76BB50}">>

<FileId='ServiceExeFile' Name='AuthenticationBusinessService.Hosting.exe'>

            Source='Files"AuthenticationBusinessService.Hosting.exe'>

            KeyPath='yes'Vital='yes'DiskId='1' />      >

      <FileId='AuthenticationBusinessService.Hosting.exe.config'                   >

            Name=' AuthenticationBusinessService.Hosting.exe.config'>

Source='Files"AuthenticationBusinessService.Hosting.exe.config'>

Vital='yes' DiskId='1' />>

>

      <!-- IMPORTANT: ServiceInstall Id and Name MUST MATCH SerivceControl Id and Name -->>

<ServiceInstallId='ServiceExeFile'>

      DisplayName= Authentication Business Service'Name='AuthenticationBusinessService'>

      ErrorControl='normal'Start='auto'Type='ownProcess'Vital='yes'>

      Description='Authentication Business Service'>

      Account='[SERVICEACCOUNTUSERNAME]'Password='[SERVICEACCOUNTPASSWORD]' /> >

<ServiceControlId='ServiceExeFile'>

      Name='AuthenticationBusinessService'>

      Start='install'Stop='both'Remove='uninstall'Wait='yes' />>

</Component>>

Posted by Jeff Wharton at 11:42 PM    

转载于:https://www.cnblogs.com/jerryzhao/archive/2008/02/07/1065677.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值