Kaleb Pederson
Kaleb Pederson

Reputation: 46479

How do I install an ASP.NET MVC 3 application on IIS 6 using WIX?

Here's some considerations when installing onto IIS-6:

And here's what I have so far:

<iis:WebDirProperties Id='WebDirProperties' Script='yes' Read='yes
  Execute='no' WindowsAuthentication='yes' AnonymousAccess='no' 
  AuthenticationProviders='NTLM,Negotiate' />

<!-- SO has some good posts on selecting the website from a dropdown -->
<iis:WebSite Id='SelectedWebSite' Directory='WWWROOT' SiteId='[WEBSITE_ID]' Description='[WEBSITE_DESCRIPTION]'>
  <iis:WebAddress Id='AllUnassigned' Port='80' IP='*'/>
</iis:WebSite>

  <Component Id="ProjWebApp" Guid="{B4BE9223-7109-4943-AE4E-8F72FA350D02}" 
    Win64="$(var.IsWin64)" NeverOverwrite="yes" Transitive="yes">
    <CreateFolder/>

    <iis:WebAppPool Id="ProjAppPool" Name="[APPPOOLNAME]" Identity="networkService"
      ManagedRuntimeVersion="v4.0" ManagedPipelineMode="integrated" />
    <iis:WebVirtualDir Id="ProjVDir" DirProperties="WebDirProperties"
      Alias="[WEBAPPNAME]" Directory="WEBFILESDIR" WebSite="SelectedWebSite">
      <iis:WebApplication Id="ProjApp" Name="[WEBAPPNAME]" WebAppPool="ProjAppPool">
        <iis:WebApplicationExtension
            CheckPath="no"
            Script="yes"
            Executable="[ASPNETISAPIDLL]"
            Verbs="GET,HEAD,POST"
            />
      </iis:WebApplication>
    </iis:WebVirtualDir>
  </Component>

  <!-- other apps may start using it once installed so it must be permanent -->
  <Component Id="EnableASPNet4Extension" Permanent="yes" Guid="{C8CDAB96-5DDC-4B4C-AD7E-CD09B59F7813}">
    <iis:WebServiceExtension Id="ASPNet4Extension" Group="ASP.NET v4.0.30319"
      Allow="yes" File="[ASPNETISAPIDLL]" Description="ASP.NET v4.0.30319" 
      UIDeletable="no"
      />
  </Component>

And I have a custom action to register ASP.NET with IIS:

<?if $(var.Platform) = x64 ?>
  <CustomAction Id="SetProperty_AspNetRegIIS_InstallNet40Cmd"
    Property="AspNetRegIIS_InstallNet40Cmd"
    Value="&quot;[NETFRAMEWORK40FULLINSTALLROOTDIR64]aspnet_regiis.exe&quot; -ir"/>
<?else?>
  <CustomAction Id="SetProperty_AspNetRegIIS_InstallNet40Cmd"
    Property="AspNetRegIIS_InstallNet40Cmd"
    Value="&quot;[NETFRAMEWORK40FULLINSTALLROOTDIR]aspnet_regiis.exe&quot; -ir"/>
<?endif?>

The Problem

This almost works. There are two problems at this point:

  1. The IIS extension doesn't respect the managed runtime version on IIS-6, so the application doesn't have an ASP.NET version set.
  2. If I use aspnet_regiis.exe -s APP_PATH to register it once it's created, it overwrites the wildcard mapping (and I don't know a commandline that I can run to restore it).

Given the above shortcomings, how can I use WIX to install an ASP.NET MVC 3 application onto IIS-6 with a proper wildcard mapping when it already has ASP.NET 2 installed?

Upvotes: 4

Views: 1354

Answers (1)

Kaleb Pederson
Kaleb Pederson

Reputation: 46479

It turns out this was a dumb error on my part. The above is sufficient to make ASP.NET v4 applications work when the pieces that I didn't include (custom actions and property definitions) are correct.

In my case, I had accidentally quoted the path to the aspnet_isapi.dll, so it wasn't actually being picked up correctly.

The IIS extension doesn't respect the managed runtime version on IIS-6, so the application doesn't have an ASP.NET version set.

That's partially true. Although it doesn't use the managed runtime version when setting the App Pool, IIS actually picks up the ASP.NET version as soon as something is correctly mapped to the aspnet_isapi.dll. As soon as I fixed the path, everything worked correctly.

If I use aspnet_regiis.exe -s APP_PATH to register it once it's created, it overwrites the wildcard mapping (and I don't know a commandline that I can run to restore it).

You can use adsutil.vbs in order to manage this if need be:

C:\Inetpub\AdminScripts>adsutil.vbs enum w3svc/998577302/root/AppName
KeyType                         : (STRING) "IIsWebVirtualDir"
...
ScriptMaps                      : (LIST) (1 Items)
  "*,C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll,1,GET,HEAD
,POST"

By using the set command in adsutil.vbs you can set the ScriptMaps property as needed.

Upvotes: 2

Related Questions