How to Create a Website and Virtual Directory with Windows Installer Xml(WiX)

Following sample wxs file demonstrates how to create an MSI to install a web site and virtual directory.

<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
   <Product Id='6197b262-b2d8-464c-9d0b-6cade171b46f' Name='WixWebSiteExample' Language='1033' Version='0.0.0.0' Manufacturer='Corporation'>
      <Package Id='439d5627-cc07-4a41-9f50-b201ae3f8202' Description='Creating a web site with WiX' Comments='Creating a web site with WiX' InstallerVersion='200' Compressed='yes' />

      <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />

      <Directory Id='TARGETDIR' Name='SourceDir'>
         <Directory Id='ProgramFilesFolder' Name='PFiles'>
            <Directory Id='ApplicationFolder' Name='AppDir' LongName='Test Directory'>
               <Component Id='WebSiteComponent' Guid='6b27e78e-bcbc-462a-bd7a-50cf991c7d39' DiskId='1'>
                  <File Id='WixExampleFile' Name='simple.txt' src='bin\simple.txt' />
                  <WebSite Id='DefaultWebSite' Description='My First Web Site Created With WiX' Directory='ApplicationFolder'>
                    <WebAddress Id="AllUnassigned" Port="80" />
                  </WebSite>
               </Component>
               <Component Id="WebVirtualDirComponent" Guid="8d7c59c0-b84d-40d9-b3a5-0c73b6487ae4">
                   <WebVirtualDir Id="VDir" Alias="Test" Directory="ApplicationFolder" WebSite="DefaultWebSite">
                       <WebApplication Id="TestWebApplication" Name="Test" />
                   </WebVirtualDir>
               </Component>
            </Directory>
         </Directory>
      </Directory>

      <Feature Id='TestProductFeature' Title='Wix File Product Feature' Level='1'>
         <ComponentRef Id='WebSiteComponent' />
         <ComponentRef Id='WebVirtualDirComponent' />         
      </Feature>
   </Product>
</Wix>

Then you need to compile your WiX file and link it.

         >candle website.wxs
         >light -out wixsite.msi website.wixobj sca.wixlib 
         >msiexec /i wixsite.msi

Note that you need to link wixobj with sca.wixlib which is located at your wix\ca folder. Above sample shows you how to create anew web site. If you just want to create a virtual directory under an existing web site, you just need to move the WebSite element out of the Component node. If a new site specifies a port number that collides with the port used by an existing web site, the existing web site will be modified, otherwise a new site will be created.

See also

  • Introduction to the Windows Installer XML(WiX) Toolset
  • MSI basics
  • WiX Tutorial - Steps to Create an MSI with Windows Installer XML(WiX)
  • How to Install a COM DLL with Windows Installer XML(WiX)
  • How to Add a License Agreement UI to Windows Installer XML(WiX)
  • How to Add Customization Code CustomAction to Windows Installer XML(WiX)
  • How to Reset Windows Service with Windows Installer XML(WiX)
  • How to Troubleshoot MSI Installation
  • How to Pass Parameters to the Customization Code(CustomAction)
  • How to Log Tracing Infomation to the Calling MSI from CustomAction
  • How to Invoke InstallUtil.exe to Call Your Managed Installer Class
  • How to Create a Website and Virtual Directory with Windows Installer XML(WiX)
  • How to Install Files to an Arbitrary Location Outside "Program Files"
  • How to Read Configuration Parameters from Xml File
  • How to Use Environmental Variables and WiX Preprocessor
  • Download WiXSharp



  • THIS POST IS PROVIDED "AS-IS" WITH NO WARRANTIES AND CONFERS NO RIGHTS. Build time: Sun 01/27/2008 . ©2007 Dalun Software. All rights reserved. Back to Article List