views:

3808

answers:

4

For IIS6 I can use the IIS helpers in Wix to install a web application like this:

<iis:WebAppPool 
    Id="AP_MyApp" 
    Name="My Application Pool" 
    Identity="networkService" />
<iis:WebApplication 
    Id="WA_MyApp" 
    Name="MyApp" 
    WebAppPool="AP_MyApp">
    <iis:WebApplicationExtension
        CheckPath="no"
        Executable="[NETFRAMEWORK20INSTALLROOTDIR]aspnet_isapi.dll"
        Verbs="GET,HEAD,POST"/>
</iis:WebApplication>

Unfortunately, this doesn't work for IIS7. We don't want to use the aspnet_isapi.dll mechanism, and instead want the integrated pipeline to handle the request routing. The app pool created by this script is in Classic mode not Integrated mode so none of the handlers get run correctly.

How can I correctly install an MVC app on IIS 7?

+2  A: 

The IIS extensions for WIX don't support IIS7. The IIS team keep rewriting the metabase between versions. There are quite a few things that don't work, the lack of an integrated app pool amongst them.

Until the extensions get rewritten, you're left with three options:

  • Use build in custom actions to invoke appcmd.exe
  • Use XmlConfig to update applicationHost.config
  • Write your own custom actions

I've opted for the xmlconfig option at the moment as you can do this within a component and tie it to a feature.

matthewthurlow
That's not exactly true. Mike has done a lot of work to get IIS7 supported by the existing CustomActions. Unfortunately, the code only supports the "legacy" stuff. As noted above, integrated pipe-line needs custom code.
Rob Mensching
OK - I wasn't aware work was being done to support IIS7 - I saw a comment suggesting Apache support may come sooner :pI was under the impression that some stuff worked if you switched on IIS6 metabase compatability and that was it.Good to hear.
matthewthurlow
To be clear, you still need IIS6 metabase compatability but, at least, it should work.And that was my off hand comment when I was pissed at IIS.
Rob Mensching
+1  A: 

Well, unfortunately the IIS extentions is not supported by IIS7 yet.

alexn
+3  A: 

Thanks to @matthewthurlow, I was able to use the XML utils to achieve what I needed to do:

<util:XmlFile 
    Id="ModifyAppPoolPipelineType"
    Action="setValue"
    ElementPath="//configuration/system.applicationHost/applicationPools/add[\[]@name='My Application Pool'[\]]/@managedPipelineMode"
    File="[WindowsFolder]System32\inetsrv\config\applicationHost.config"
    Value="Integrated"/>

The rest of the actions do seem to work fine with IIS 7.

Simon Steele
When uninstalling how do you take the entry out ?
CheGueVerra
+7  A: 

I personally recommend using AppCmd.exe (matthewthurlow's first bullet) because you don't have to count on the legacy management components being installed, or risk modifying the configuration XML manually.

If you are not comfortable with AppCmd, Mike Volodarsky has a great article on Getting Started with AppCmd.exe, and the Microsoft IIS Configuration Reference is excellent, offering UI, Code and AppCmd examples for modifying each of the configuration items (e.g. Application Pools ). The IIS7 Administration Pack also includes a Configuration Editor that allows you to generate AppCmd scripts from any existing configuration.

To integrate AppCmd into WiX, you need to create and schedule two custom actions for each command. There is general information in the WiX v3 manual documenting this procedure, and I've included a concrete example below.

First, you need to set up an immediate action to store the command line in a property:

<CustomAction 
  Id="CreateAppPool_Cmd" 
  Property="CreateAppPool" 
  Execute="immediate" 
  Value="&quot;[WindowsFolder]system32\inetsrv\APPCMD.EXE&quot; add apppool /name:&quot;[APP_POOL_NAME]&quot;" />

Next you set up a deferred action which references this property:

<CustomAction 
  Id="CreateAppPool" 
  BinaryKey="WixCA" 
  DllEntry="CAQuietExec" 
  Execute="deferred" 
  Return="ignore" 
  Impersonate="no"/>

And finally, you need to schedule these. The immediate action that sets the properties seem to work well after InstallFinalize, and the deferred action works after InstallFiles. I haven't got as far as figuring out rollback actions yet.

MapGuide Open Source does this method extensively; you can see the CA scheduling in our MapGuide.wxs file, and the CA definition in our IIS7.wxs file.

JasonBirch
Thanks for the good information Jason!
Si
This was very useful to me yesterday, and thanks for the links to the examples too!
Simon Steele