5

How can I convert a directory under a virtual directory to an application, using WIX?

WIX installs the following Virtual Directory to IIS, and I wish it to also convert the webservice folder to an application.

Community
  • 1
  • 1
staterium
  • 1,980
  • 2
  • 20
  • 32

4 Answers4

8

I could not find a way to do this through WIX or the IIS extension, so I resorted to calling an external command. For future reference, the commands are:

IIS 5

C:\Inetpub\AdminScripts\mkwebdir.vbs -c Localhost -w "Default Web Site" -v "sentry/webservice","{physical path}"
C:\Inetpub\AdminScripts\adsutil.vbs appcreateinproc w3svc/1/root/sentry/webservice

IIS 6

C:\Windows\System32\iisvdir.vbs /create "Default Web Site/Sentry/webservice" webservice "{physical path}"

IIS 7

C:\Windows\System32\inetsrv\appcmd add app /site.name:"Default Web Site" /path:/Sentry/webservice /physicalPath:"{physical path}"
staterium
  • 1,980
  • 2
  • 20
  • 32
2

This can be done with the IISExtension, as Daniel Morritt suggests. As it's very difficult to find sample code for this I thought I'd post how I did it.

<!-- Your example uses the default web site. -->
<iis:WebSite Id="DefaultWebSite" Description="Default Web Site" SiteId="*">
  <iis:WebAddress Id="DefaultWebAddress" Port="80"/>
</iis:WebSite>

<!-- Web Dir Properties to enable access to a Web Application. -->
<iis:WebDirProperties Id="AnonymousExecuteAndScript" 
                      Read="yes" 
                      Write="no" 
                      Execute="yes" 
                      Script="yes" 
                      AnonymousAccess="yes" 
                      Index="no" 
                      LogVisits="no"/>

<!-- Assumes the presence of this directory reference. -->
<DirectoryRef Id="SentryWebServiceDir">
  <Component Id="SentryWebServiceComponent" Guid="{GUID-GOES-HERE}">

    <iis:WebVirtualDir Id="SentryWebService"
                       DirProperties="AnonymousExecuteAndScript" 
                       Alias="Sentry/webservice"
                       Directory="SentryWebServiceDir"
                       WebSite="DefaultWebSite">

      <!-- Make this virtual directory a web application -->
      <iis:WebApplication Id="SentryWebServiceApp" Name="webservice" WebAppPool="DefaultAppPool"/>
    </iis:WebVirtualDir>

    <!-- Workaround for the need for a KeyPath for this component. -->
    <RegistryValue Root="HKLM"
              Key="SOFTWARE\YourCompany\Sentry\WebService"
              KeyPath="yes"
              Value="1"
              Type="binary"
              Name="Installed"
              Id="SentryWebServiceInstalled"/>
  </Component>
</DirectoryRef>

All of the above can be nested in a <Fragment> element.

0

I have tested this approach, and it works:

http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg04374.html

It says to put the whole path in the Alias, for example

<iis:WebVirtualDir Id="VIRTDIR_Sentry_webservice"
                       Directory="WebService"
                       Alias="Sentry/webservice"
                       WebSite="SITE_Default"> ...
Maate
  • 1,000
  • 1
  • 6
  • 15
0

You can add a reference to the WiX IISExtension to your project and create one using this.

A good example of this can be found here: Using WiX to create an IIS virtual directory

Community
  • 1
  • 1
Daniel Morritt
  • 1,787
  • 17
  • 25
  • That is the way the existing Sentry Virtual Directory is created, and does not work for creating an application under an existing virtual directory (note the 'Website' property of iis:WebVirtualDir) – staterium Jan 16 '12 at 12:31