Install a New Virtual Directory to Default Web Site with WiX

Sometimes the internet is totally awesome and other times it’s a complete morass of “how come I can’t find anything?” Recently, I needed to build a quick installer that did nothing more than install new virtual directory under the ubiquitous Default Web Site. I thought installing a basic web site would have been a very common task and was sure there were fifty to sixty examples out there in the blogsphere. However, the internet failed me, which has to be the first time in recorded history that’s ever happened.

Fortunately, there was enough documentation out there that pointed me in the right direction. What’s below is the core .WXS file for an installer that meets the following requirements:

· Verifies that IIS is installed

· Finds the physical path for the Default Web Site

· Installs a specifically named virtual directory under Default Web Site

· Installs the files into a named directory under the Default Web Site physical path

As you can see, the WiX 3.5 code isn’t that exciting, but I thought it would be useful for new WiX developers to see and better yet, steal. Here’s the download for the entire project.

<?xml version=1.0 encoding=UTF-8?>
<
Wix xmlns=http://schemas.microsoft.com/wix/2006/wi
     xmlns:iis=http://schemas.microsoft.com/wix/IIsExtension
>

<?
define ProductUpgradeCode=”da7c5352-634c-408c-ad5c-5ff806106378″
?>

<?
define InstallVersion=”1.0.0.0″
?>

<
Product Id=*
           Name=Basic Web App Install Example
           Language=1033
           Version=$(var.InstallVersion)
           Manufacturer=John Robbins/Wintellect
           UpgradeCode=$(var.ProductUpgradeCode)
>
<
Package Id=*
             Description=A simple web site installation
             Comments=Just showing how it works.
             Manufacturer=John Robbins/Wintellect
             InstallerVersion=300
             Languages=1033
             Compressed=yes
             SummaryCodepage=1252
             InstallPrivileges=elevated/>
 
   
<
MajorUpgrade Schedule=afterInstallInitialize
                  DowngradeErrorMessage=A later version of [ProductName] is
already installed. Setup will now exit.
/>
 
   
<
Property Id=IIS_MAJOR_VERSION
>
<
RegistrySearch Id=CheckIISVersion

Root=HKLM

Key=SOFTWAREMicrosoftInetStp
                      Name=MajorVersion
 
                     Type=raw
/>
</
Property>
 
    <Condition Message=IIS must be installed>
      Installed OR IIS_MAJOR_VERSION
    </Condition>
 
   
<
Property Id=IISROOT
>
<
RegistrySearch Id=IISROOT
                      Type=directory
                      Root=HKLM
                      Key=SoftwareMicrosoftInetStp
                      Name=PathWWWRoot
/>
</
Property>
 
    <Condition Message=IIS does not appear to be installed correctly, the
root directory is not set.
>
      Installed OR IISROOT
    </Condition>
 
   
<
Media Id=1 Cabinet=media1.cab EmbedCab=yes />
 
   
<
Directory Id=TARGETDIR Name=SourceDir
>

<
Directory Id=IISROOT Name=WebDir
>

<
Directory Id=INSTALLDIR
                   Name=BasicWeb>
 
         
<
Component Id=WebVirtualDirComponent
                     Guid=D814F88F-6E0C-4365-A411-2F9807522C3D
>




<
iis:WebVirtualDir Id=VDir
                               Alias=BasicWeb
                               Directory=INSTALLDIR
                               WebSite=DefaultWebSite
>

<
iis:WebApplication Id=TestWebApplication
                                  Name=BasicWeb
/>
</
iis:WebVirtualDir
>

<
CreateFolder
/>
</
Component
>
</
Directory
>
</
Directory
>
</
Directory>
 
   
<
iis:WebSite Id=DefaultWebSite
                 Description=Default Web Site
                 Directory=INSTALLDIR
>

<
iis:WebAddress Id=AllUnassigned Port=80
/>
</
iis:WebSite>


    <Feature Id=TestProductFeature Title=Wix File Product Feature Level=1
>
<
ComponentRef Id=WebVirtualDirComponent
/>
<
ComponentGroupRef Id=BASICWEBAPPFILES
/>
</
Feature
>
</
Product
>
</
Wix
>

< p style=”line-height:normal;margin:0in 0in 0pt;background:#dbe5f1″ class=”MsoNormal”> 

Stay Informed

Sign up for the latest blogs, events, and insights.

We deliver solutions that accelerate the value of Azure.
Ready to experience the full power of Microsoft Azure?

Atmosera is thrilled to announce that we have been named GitHub AI Partner of the Year.

X