Search code examples
wixwindows-installeriswix

Creating a Virtual Directory on IIS using IsWix


I'm creating an IsWix solution that creates an IIS with a static javascript website. The website is working as expected after the instalation when I enter to localhost:8080

The problem starts here, I'm unable to serve this website on a virtual directory.

I want to be able to use localhost/myApp to browse the app.


Solution

  • In your main project under Code\IISMeta.wxs you'll find the markup that defines the IIS configuration. This file can express any valid WiX IIS meta as documented here:

    https://wixtoolset.org/documentation/manual/v3/xsd/iis/

    A basic example (needs some tweaking) would look something like this:

    <Directory Id="webSites" Name="WebSites">
                <Component Id="webSite" Guid="PUT_GUID_HERE" KeyPath="yes" Permanent="yes">
                  <CreateFolder />
                  <iis:WebSite Id="DefaultWebSite" SiteId="*" Description="Default Web Site" Directory="webSites" ConfigureIfExists="no" >
                    <iis:WebAddress Id="webSite" Port="80" />
                    <iis:WebDirProperties Id="webSite" AnonymousAccess="yes" WindowsAuthentication="no" />
                  </iis:WebSite>
                </Component>
              <Directory Id="webSiteUi" Name="UI">
                <Component Id="webSiteUi" Guid="PUT GUID HERE" KeyPath="yes">
                  <iis:WebAppPool Id="webSiteUi" Name="WebSiteUI" Identity="networkService" ManagedRuntimeVersion="v4.0" ManagedPipelineMode="Classic" />
                  <iis:WebVirtualDir Id="webSiteUi" Alias="Something" Directory="webSiteUi" WebSite="DefaultWebSite">
                    <iis:WebDirProperties Id="webSiteUi" AnonymousAccess="yes" WindowsAuthentication="no" />
                    <iis:WebApplication Id="webSiteUi" WebAppPool="webSiteUi" Name="Something" />
                  </iis:WebVirtualDir>
                </Component>
              </Directory>