I’ve just tried out creating a virtual directory with Wix and there’s really not that much too it, there’s a couple of places where the syntax isn’t that intuitive but the compiler nudges you in the right direction. I thought I’d share my experience anyway as the Wix post seem quite popular and it’s often nice to have a template to start from if you’re setting out to do these things.

 

There’s just three parts to it, first you create the files for you’re website in the location of you’re choosing. Something like this:

 

<Directory Id="ProgramFilesFolder" Name="PFiles">

<Directory Id="InstallDir" Name="TEST" LongName="Test" >

<Component Id="default.htmlComponent" Guid="af0b56d1-7660-4172-9f16-a4e29d343341">

<File Id="default.htmFile" Name="DEFUALT.HTM" LongName="default.htm" KeyPath="yes" DiskId="1" src="default.htm" />

</Component>

</Directory>

</Directory>

 

Then create the entries for the virtual directory itself, you don’t really need the “WebApplication” node but most of the time when you create a virtual directory you create it in its own application.

 

<Component Id="TestWebVirtualDirComponent" Guid="054604ca-1790-4c0c-b076-531ff9a5b374">

<WebVirtualDir Id="TestWebVirtualDir" Alias="Test" Directory="InstallDir" WebSite="DefaultWebSite">

<WebApplication Id="TestWebApplication" Name="Test" />

</WebVirtualDir>

</Component>

 

Finally you need an entry to reference the web site itself; because you don’t want this to be created it is placed under the product node. Not much to say about this, except you need the “WebAddress” node even though it doesn’t really provide any extra info.

 

<WebSite Id="DefaultWebSite" Description="Default Web Site">

<WebAddress Id="AllUnassigned" Port="80" />

</WebSite>

 

As discussed in a pervious blog post you will need to include the wix server custom actions for this to work correctly.

 

The only real problem I found was that it only seems to work with IIS 6.0, installing on an IIS 5.5 machine gives the rather cryptic error “Product: Test Virtual Dir -- Error 1316. A network error occurred while attempting to read from the file: C:\wixinstalls\virtualdir\output\testuser.msi”. I’ll be reporting this to the bug tracking tool, so I guess we’ll soon find out weather this is a bug or a feature.

 

Download the complete source here.

Feedback:

Feedback was imported from my only blog engine, it's no longer possible to post feedback here.

re: Creating a virtual directory with Wix works a treat - Chris Bilson

This is excellent information. Information about using the CustomActions is hard to come by. I am in the process of trying to do this for an installer for a product I work on, and several times have considered giving up writing what I want in C++. Thanks!

re: Creating a virtual directory with Wix works a treat - 龙龙

I had meet Your error “Product: Test Virtual Dir -- Error 1316. A network error occurred while attempting to read from the file: C:\wixinstalls\virtualdir\output\testuser.msi”. It's the product ID problem. I did down all samples from your blog, there product ID is same! after you install any one, when you install another will recieve this error.
I test this IIS install script, It works fine in WindowsXP or Win2003, But not work in Win2000

re: Creating a virtual directory with Wix works a treat - 龙龙

It just a very small bug.
if you change the sequence of Directory And alias in "WebVirtualDir" node, it can work fine in win2000 too.
good luck

re: Creating a virtual directory with Wix works a treat - Robert Pickering

Thanks for the info. I hope to have to revisit my samples and give them different guid soon!

re: Creating a virtual directory with Wix works a treat - Steven Melzer

Thank you. I was beating my head trying to get the correct syntax for this.

re: Creating a virtual directory with Wix works a treat - Horea

Maybe you should include a link to the original tutorial where you copied this from

http://www.tramontana.co.hu/wix/lesson6.html

re: Creating a virtual directory with Wix works a treat - Horea

Or maybe he copied it from you, nevertheless the samples look very much alike.

:)

re: Creating a virtual directory with Wix works a treat - toml

Unfortunately, when you uninstall the package, it removes the website also, even if it existed before your install.

re: Creating a virtual directory with Wix works a treat - Robert Pickering

Toml,

It shouldn't remove the website because it not marked with a GUID so should be a permitant feature. I definly didn't see this behavior when I ran the sample. Maybe you should try and pin down the exact circumstances it does this and report it as a WIX bug.

Horea,

My name appears on the credit list:
http://www.tramontana.co.hu/wix

Cheers,
Rob

re: Creating a virtual directory with Wix works a treat - Francisco

You said that WebAddress does not provide extra info. Did you try to install your application in a IIS with more than 1 website.
Try to install you application in a second Website, this website has as Identification and Ip or an Host Header...

This Web Address is the identifier that make you choose the website that you want to install you application.

Look at this:

<WebSite xmlns="http://schemas.microsoft.com/wix/IIsExtension" Id="SelectedWebSite" Description="[WEBSITENAME]">
<WebAddress Id="WebsiteIdentity" Port="[WEBSITEPORT]" Header="[WEBSITEHEADER]" IP="[WEBSITEIP]" />
</WebSite>

re: Creating a virtual directory with Wix works a treat - Román

Rob

Although this post is quite old, I am trying to create a virtual directory using that same example, but still there are two things I'm not happy with (I'm using WiX 3):
1- If I don't specify a CreateFolderElement under the component that creates the virtual directory, Votive gives me an ICE18 compilation error.If I do, the installer also creates a web directory under the DefaultWebSite, alongside the virtual directory, with the same path.
2- I'm trying to create a parent directory P restricted to SSL access and a child directory C without SSL access to which I want to redirect the users after a HTTP 403.4. The setting on P works fine, but I have to go to IIS to change the setting for C manually.

Any idea of how to solve this issues?

Thanks in advance
Román