What I would like to do is show the installer user a list of the websites on their server and allow them to choose one (using the method described here: http://www.cmcrossroads.com/content/view/13160/120/, which now seems broken see here for the core code). The installer would then create a virtual directory in the chosen website.
However, my searching seems to have revealed that the only way to specify a website in WiX is by IP, Port, and Header. Asking for these is not very user friendly, so I'm left with the idea of writing a second custom action to get those details from a website name.
Is there a better way?
BTW This needs to work in both IIS6 and IIS7 in case that affects the answer.
Whilst this question and answer are still valid, I think it's worth asking yourself whether you really want to use the website name. I you want to store it for use during uninstallation then saving the site ID is probably a better idea. In which case the website element becomes:
OK it is possible (in IIS6 or IIS7 with Metabase compatibility), thanks to this post to the mailing list explaining the slightly bizarre way the iis:Website element works. The useful part is:
So my WiX code ends up looking like:
The iis:WebAddress element should never be used but is necessary for the project to compile.
Reply on For
IisEnumSites:Exception: 0x80004005 : Modify, Mode, Record
I have similar experience and what I found so far is the site Id that extract from
parseInt
:I have a website with a name like
W3SVC/1528550093
and I suspect1528550093
is too big for theAvailableWebSites
table.Once I have the if statement to filter out these big number, and the script work fine.
Hope this help for other.
In my installer I didnt want to create a Web site. I wanted to allow the user to select an existing website. I did this with a custom action in Javascript, and one custom UI panel.
Custom Action code:
Register the Custom Actions like this:
This is the .wxs for the UI Panel:
The UI panel presents a listbox, which is automatically populated with elements from the ListBox table with the first field of WEBSITE. This table is populated at runtime by the custom action in Javascript.
To invoke the custom action at the right time, you need something like this in the main .wxs file: