I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX?
I do something like this
// declare Custom action
<CustomAction Id="MakeWepApp20" Value="[NETFRAMEWORK20DIR]aspnet_regiis.exe" -sn "W3SVC/[WEBSITEIISID]/Root/" />
<InstalllExecuteSequence>
...
<Custom Action="MakeWepApp20" after="ConfigureIIs">
[Your conditions here]
</Custom>
First find the correct .NET version folder. Use DirectorySearch/FileSearch to perform search.
Use the above path to call aspnet_regiis.exe and set the version for the webapp from a custom action.
aspnet_regiis.exe -s W3SVC/1/ROOT/SampleApp1
I found a different way by using the WiX WebApplicationExtension. You can check out the full solution here and here.
I like Wix so far, but man does it takes a lot of digging to find what you are looking for.
We use this:
First determine the .Net framework root directory from the registry:
<Property Id="FRAMEWORKROOT">
<RegistrySearch Id="FrameworkRootDir" Root="HKLM"
Key="SOFTWARE\Microsoft\.NETFramework"
Type="directory" Name="InstallRoot" />
</Property>
Then, inside the component that installs your website in IIS:
<!-- Create and configure the virtual directory and application. -->
<Component Id='WebVirtualDirComponent' Guid='{GUID}' Permanent='no'>
<iis:WebVirtualDir Id='WebVirtualDir' Alias='YourAlias' Directory='InstallDir' WebSite='DefaultWebSite' DirProperties='DirProperties'>
<iis:WebApplication Id='WebApplication' Name='YourAppName' WebAppPool='AppPool'>
<!-- Required to run the application under the .net 2.0 framework -->
<iis:WebApplicationExtension Extension="config" CheckPath="yes" Script="yes"
Executable="[FRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" Verbs="GET,HEAD,POST" />
<iis:WebApplicationExtension Extension="resx" CheckPath="yes" Script="yes"
Executable="[FRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" Verbs="GET,HEAD,POST" />
<iis:WebApplicationExtension Extension="svc" CheckPath="no" Script="yes"
Executable="[FRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" Verbs="GET,HEAD,POST" />
</iis:WebApplication>
</iis:WebVirtualDir>
</Component>
For an x64 installer (THIS IS IMPORTANT) Add Win64='yes' to the registry search, because the 32 bits environment on a 64 bits machine has a different registry hive (and a different frameworkroot)
<RegistrySearch Id="FrameworkRootDir" Root="HKLM"
Key="SOFTWARE\Microsoft\.NETFramework"
Type="directory"
Name="InstallRoot" Win64='yes' />
Here is what worked for me after wrestling with it:
<Property Id="FRAMEWORKBASEPATH">
<RegistrySearch Id="FindFrameworkDir" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework" Name="InstallRoot" Type="raw"/>
</Property>
<Property Id="ASPNETREGIIS" >
<DirectorySearch Path="[FRAMEWORKBASEPATH]" Depth="4" Id="FindAspNetRegIis">
<FileSearch Name="aspnet_regiis.exe" MinVersion="2.0.5"/>
</DirectorySearch>
</Property>
<CustomAction Id="MakeWepApp20" Directory="TARGETDIR" ExeCommand="[ASPNETREGIIS] -norestart -s W3SVC/[WEBSITEID]/ROOT/[VIRTUALDIR]" Return="check"/>
<InstallExecuteSequence>
<Custom Action="MakeWepApp20" After="InstallFinalize">ASPNETREGIIS AND NOT Installed</Custom>
</InstallExecuteSequence>
[WEBSITEID] and [VIRTUALDIR] are properties you have to define yourself. [VIRTUALDIR] is only necessary if you are setting the ASP.NET version for an application rather than an entire website.
The sequencing of the custom action is critical. Executing it before InstallFinalize will cause it to fail because the web application isn't available until after that.
Thanks to Chris Burrows for a proper example of finding the aspnet_regiis executable (Google "Using WIX to Secure a Connection String").
jb
But where can I get [WEBSITEID] of my site for command-line parameters of aspnet_regiis command? I found it is varies IIS by IIS from server to server...
Don't forget to enable ASP 2.0 on the server
<iis:WebServiceExtension Id="ExtensionASP2" Group="ASP.NET v2.0.50727" Allow="yes" File="[NETFRAMEWORK20INSTALLROOTDIR]aspnet_isapi.dll" Description="ASP.NET v2.0.50727"/>