views:

22

answers:

2

I have a Wix installed which creates a virtual directory in IIS via the following:

<DirectoryRef Id="INSTALLLOCATION">
  <Component Id="VirtualDirectory" Guid="29BEECCC-AA5F-11DF-BBB1-9C0AE0D72085">
    <iis:WebVirtualDir Id="MyVDir" Directory="INSTALLLOCATION" Alias="MyVDir" WebSite="DefaultWebSite">
      <iis:WebApplication Id="MyApplication" Name="MyVDir" />
    </iis:WebVirtualDir>
    <CreateFolder />
  </Component>
</DirectoryRef>
<iis:WebSite Id="DefaultWebSite" Description="Default Web Site">
  <iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>

However this fails if the bindings for port 80 have been removed for that web site.

The <iis:WebAddress /> element and Port attributes are both mandatory, however completely superfluous in this case - I don't care what the Port of the web site is, as long as it creates my virtual directory!

Is there any way of getting the above installer to successfully create a virtual directory without prompting the user for a port number?

A: 

All virtual directories are rooted in a web site. The WebSite element can be used to create a web site if WebSite element is under Component element or used to find a web site if not. The VirtualDir element must refer to a WebSite element somehow. That's the design of IIS thus the WiX models this way.

Note: One might argue that WebSite element not under a Component element should have been named "WebSiteSearch" or something.

Rob Mensching
I get that the VirtualDir element must refer to a WebSite element somehow, however why does the WebSite element need to explicitly specify a port even when using an existing site?
Kragen
I have a number of sites on my IIS7 and most of them has virtual dirs and I didn't saw any mentions between root site and others
abatishchev
WebSite element has slowly morphed over time to allow different ways of finding the web site you want. Originally, the thinking is that the only guaranteed unique value for a web site was its port. Later we added the ability to find the web site by id and by description. Take a look at the documentation. The element is a bit more complex than it should be at this point because our understanding of IIS morphed over time... and IIS changed guidance from IIS5 to IIS6 to IIS7.
Rob Mensching
A: 

I've found that as long as the SiteId attribute is provided the port is in fact ignored. The solution to my problem was to therefore change my WebSite element to be:

<iis:WebSite Id="DefaultWebSite" Description="Default Web Site" SiteId="*">
  <iis:WebAddress Id="AllUnassigned" Port="1" />
</iis:WebSite>

Note that the Port attribute is still required (and cannot be 0), however is ignored even if the SiteId attribute is * (meaning that the description is used to identify the site).

See WebSite Element (WiX documentation) for more information.

Kragen