Friday, May 4, 2012

Wix: where is my web application created?

Installing a web application, I want to select on wich web site it suppose to be created.
So, I let's say I have 2 web sites:

Default Web Site listening on *:80
Test Web Site listening on *:8080

In my wix code I write smth like that:

<iis:WebSite Id='SelectedWebSite'
                 Description='[WEBSITE_NAME]'
                 Directory='INSTALLDIR'>
      <iis:WebAddress Id="AllUnassigned" Port="80"/>
</iis:WebSite>

AND I put this under Product, since I am not interested in my web site being created on install and removed on uninstall, i.e. I ask user to choose from existing web sites (details see here: http://wix.sourceforge.net/manual-wix3/iis_xsd_website.htm)

So far so good. Moving on - to virtual dir and web application itself.
Under dedicated component  write this:
     
 <iis:WebVirtualDir Id="VDir"
                                Alias="[WEB_APP_NAME]"
                                Directory="INSTALLDIR"
                                WebSite="SelectedWebSite">
           <iis:WebApplication Id="MyWebAppApplication"
                                             WebAppPool="SelectedAppPool"
                                             Name="[WEB_APP_NAME]" />
           <iis:WebDirProperties Id="SelectedWebSite_Properties"
                                                AnonymousAccess="yes
                                                WindowsAuthentication="no"
                                                DefaultDocuments="Default.aspx" />
</iis:WebVirtualDir>              
                        
So I start installation and select Test Web Site to install under. What do I expect? Virtual directory and web application being created under selected web site.
But hold on, it is not that easy!

In that case, virtual directory is located under the right place, but web application ended up under Default Web Site. Why is that? Becouse it is Default Web Site listening to *:80, and that(*:80) is specified in iis:WebAddress part under iis:WebSite.
Just to make sure, I changed  to <iis:WebAddress Id="AllUnassigned" Port="8080"/> - and vuala, this time my web application ended up under correct Test Web Site.

Interesting...


No comments:

Post a Comment