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:
<?xml version="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)
-->>
<Wix xmlns="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:User Id ='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:WebSite Id='DefaultWebSite' Description='Default Web Site'>>
<iis:WebAddress Id='AllUnassigned' Port='80' />>
</iis:WebSite>
>
Define Default Virtual Directory Properties>
>
<iis:WebDirProperties Id='WebVirtualDirProperties' Execute='yes' Script='yes' Read='yes' WindowsAuthentication='no'>
AnonymousAccess='yes' AnonymousUser='serviceAccount' IIsControlledPassword='yes'/>
>
>
Create an Application Pool in IIS 6.0>
<Component Id='C_MyAppPool' Guid='3C06911D-C31A-427E-8CA6-AEFC65161B1A' >>
<iis:WebAppPool Id='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.
-->>
<Property Id="TARGETVDIR" Value="AuthenticationWebService" />>
<Component Id='C_VirtualDirComponent' Guid='{A598E09C-B770-4df2-BE08-E069A718B938}'>>
<iis:WebVirtualDir Id='VirtualDir' Alias='[TARGETVDIR]' Directory='TARGETDIR'>
WebSite='DefaultWebSite' DirProperties='WebVirtualDirProperties' >>
<iis:WebApplication Id='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
-->>
<Component Id="C_ConfigFile" Guid="{8943581F-D07B-49f4-AF09-23541F7EB2F7}">>
<util:XmlFile Id='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 >
<Component Id="C_EventLogReg" Guid="{05F254DE-E990-4FD6-86B7-11200B148B36}">>
<RegistryKey Root="HKLM" Key="SYSTEM\ControlSet001\Services\Eventlog\Application\Wcf_S113" >
Action="create" />>
<RegistryValue Root="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>
>
<Component Id="ProductComponent" Guid="{ED4F5E2A-D8B6-42e7-9330-9282AA76BB50}">>
<File Id='ServiceExeFile' Name='AuthenticationBusinessService.Hosting.exe'>
Source='Files\AuthenticationBusinessService.Hosting.exe'>
KeyPath='yes' Vital='yes' DiskId='1' /> >
<File Id='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 -->>
<ServiceInstall Id='ServiceExeFile'>
DisplayName= Authentication Business Service' Name='AuthenticationBusinessService'>
ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes'>
Description='Authentication Business Service'>
Account='[SERVICEACCOUNTUSERNAME]' Password='[SERVICEACCOUNTPASSWORD]' /> >
<ServiceControl Id='ServiceExeFile'>
Name='AuthenticationBusinessService'>
Start='install' Stop='both' Remove='uninstall' Wait='yes' />>
</Component>>







15 comments:
g'day Jeff.
In your WixTravels, have you run across any construct that allows you to start and stop IIS (i.e. not IISRESET, but stop IIS at the start of an install and restart IIS after the install is done)?
Cheers
Josh Korn
Ottawa, Canada
Hi Josh,
Sure do. Please see my new post as I've reached the character limit on this one:
http://blog.wharton.com.au/2007/07/another-windows-installer-xml-wix-30.html
Cheers
Jeff
Hi Jeff,
Do you know of any way to install a service that points to an exe that will ALREADY be on the machine before install?
Our application uses a user-defined service that points to srvany.exe in the windows server 2003 resource kit folder.
Thanks,
Dan
Hi Dan,
Have a solution for you and will post it tomorrow (sorry, just got back from Tech.Ed so a bit stuffed today!).
Cheers
Jeff
Looking forward to it! Thanks so much.
Hi Dan,
Check out this http://blog.wharton.com.au/2007/08/wix-installing-windows-nt-user-defined.html
Cheers
Jeff
Thanks Jeff - this is great info!
Cheers,
David
Hey Jeff-
Have you ever tried to create a SQLEXPRESS database in Wix 3.0? I've been using the documentation and wix-users sourceforge list to guide me, but I still haven't gotten it working yet.
-Dan
Hi Jeff--
Have you ever successfully installed a SQL Server Express database using Wix? I'm having a heck of a time getting this going and am starting to wonder if it's possible.
Hi Jeff-
I am following your code above to set up a virtual directory. However, I get "The Component element contains an unhandled extension element "iis:WebVirtualDir". Please ensure that the extension in the 'http://schemas.microsoft.com/wix/IIsExtension' namespace has been provided." And, I have that namespace specified. I am not sure what could be the problem. Have you seen this error before?
Please, help.
Thanks,
DP
Hello,
I have a same problem ... I get a
The Component element contains an unhandled extension element 'iis:WebVirtualDir'. Please ensure that the extension for elements in the 'http://schemas.microsoft.com/wix/IIsExtension' namespace has been provided.
error even though the extension is there :( any help would be apreciated...
Thx,
Sergiu
Hi Jeff
Is it possible to install a web site and an application pool in IIS 7 using WiX (I'm using WiX 3.0.4130).
Regards, Yavor
Hi Jeff
I'm creating a package that installs a database on a db server. If I hardcode the server name as well as the db user name and password my code works, but is there a way to select the SQL server name and user credentials form a custom dialog box.
Regards, Yavor
Add an IISExtension reference while you run the candle.exe
eg: candle -ext WixIIsExtension Sample.wxs
Hi All,
I am using WIX 3.0 to create the MSI for my web app. On install the website, VDir, Apppool are creating correctly, but during uninstall it is not removing the VDIR and Apppool from my website, but the target directory files are getting removed. I am not sure why the vdir is not getting removed during uninstall.
Can anyone help me on this please?
Thanks
Post a Comment