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.
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}"
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.
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"> ...
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