REQUEST A DEMO

Creating Windows Installers: Web Applications and Virtual Directories

So far on our journey into building windows installers we have gone from just getting started to generating Wix content for all the files in your application. There is an important little something something missing from our toy installer. Pleats (fake product of Pants Enterprises) is supposed to be a web application that runs on IIS. It would be great to add support in the installer to create a virtual directory for the web application. With Wix this is quite easy. Here we go.

A virtual directory for your web application

 

I like to compartmentalize my units of install where practical. Because having the installer integrate with IIS and create a virtual directory is completely different than copying files I feel that this piece of the install belongs in its own component.

 


    
      
    

 

The XML above is declaring that a virtual directory called Pleats enabled as a web application should be created under the Default Web Site. The Default Web Site in this case is a reference to a <WebSite> element we will add elsewhere. The <WebVirtualDir> needs to have a <WebApplication> when you are deploying classic ASP or ASP.Net web applications.

 

...



  



...

 

Above we define the web site that is being referenced by our IIS integration.

Oops need to link to the server custom action library

 

If you add these two blocks of XML to your .wxs file and try to build the installer using the NAnt build automation I created in my previous posts you will get a linker error because we are now using Wix schema elements that are dependant on the Server Custom Action library.

 

(project root)>.\tools\nant\nant build-installer

 

NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

 

build-installer:

 

[exec] Microsoft (R) Windows Installer Xml Compiler version 2.0.5325.0
[exec] Copyright (C) Microsoft Corporation 2003. All rights reserved.
[exec] pleats.wxs
[exec] Microsoft (R) Windows Installer Xml Linker version 2.0.5325.0
[exec] Copyright (C) Microsoft Corporation 2003. All rights reserved.
[exec] C:\projects\pleats\wix\pleats.wxs : error LGHT0112 : Unresolved reference to symbol ‘CustomAction:ConfigureIIs’ in section ‘Product:A263E591-B290-4DB2-BF08-0C6FF24959A3’.

 

 

To fix this problem you just need to update the linker execution (light.exe) with a reference to the sca.wixlib here is the updated NAnt target for building the installer.

 

 

  
  

  
    
      
    
  

  
  

 

Build It, Install It

 

Building the installer should now work that the Server Custom Actions are linked in. Let’s take a look at what Internet Information Services Manager on Windows XP looks like after the installer is completed.

 

pleats-iis-snapin_thumb[3]

Conclusion

 

There is a lot more customization you can do for web application configuration. For example, want to run your web applications in their own Application Pool  use <WebAppPool>. If you using the excellent MonoRail web application framework and you want your installer to register the .castle file extension to be handled by ASP.Net I believe you can use <WebApplicationExtension> to do this rather than doing it manually.