Creating a virtual directory with Wix works a treat

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.

Bookmark
dotnetkicks+, digg+, reddit+, del.icio.us+, dzone+, facebook+

Print | posted @ Friday, October 08, 2004 7:54 AM

Comments on this entry:

Gravatar # re: Creating a virtual directory with Wix works a treat
by Chris Bilson at 10/12/2004 1:47 PM

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!
Gravatar # re: Creating a virtual directory with Wix works a treat
by 龙龙 at 10/18/2004 3:51 AM

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
Gravatar # re: Creating a virtual directory with Wix works a treat
by 龙龙 at 10/18/2004 8:43 AM

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
Gravatar # re: Creating a virtual directory with Wix works a treat
by Robert Pickering at 10/19/2004 8:09 AM

Thanks for the info. I hope to have to revisit my samples and give them different guid soon!
Gravatar # re: Creating a virtual directory with Wix works a treat
by Steven Melzer at 4/30/2005 1:44 AM

Thank you. I was beating my head trying to get the correct syntax for this.
Gravatar # re: Creating a virtual directory with Wix works a treat
by Horea at 9/14/2005 2:22 PM

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

http://www.tramontana.co.hu/wix/lesson6.html
Gravatar # re: Creating a virtual directory with Wix works a treat
by Horea at 9/14/2005 2:24 PM

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

:)
Gravatar # re: Creating a virtual directory with Wix works a treat
by toml at 9/22/2005 12:26 AM

Unfortunately, when you uninstall the package, it removes the website also, even if it existed before your install.
Gravatar # re: Creating a virtual directory with Wix works a treat
by Robert Pickering at 9/24/2005 8:54 AM

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
Gravatar # re: Creating a virtual directory with Wix works a treat
by Francisco at 9/21/2007 8:09 PM

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>
Gravatar # re: Creating a virtual directory with Wix works a treat
by Román at 8/12/2008 3:30 PM

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

Your comment:

(Note: all comments are moderated so it may take sometime to appear)

Title:
Name:
Email:
Website:
 
Italic Underline Blockquote Hyperlink
 
 
Please add 7 and 3 and type the answer here: