Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set ASP.Net version using WiX

Tags:

I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX?

like image 605
JasonS Avatar asked Oct 02 '08 17:10

JasonS


People also ask

Does Wix support .NET 6?

NET 6 runtime is installed. WiXWiXWindows Installer XML Toolset (WiX, pronounced "wicks"), is a free software toolset that builds Windows Installer packages from XML. It consists of a command-line environment that developers may integrate into their build processes to build MSI and MSM packages.https://en.wikipedia.org › wiki › WiXWiX - Wikipedia provides pre-defined properties to check this for .

How do I use Wix with Visual Studio?

To use Wix with Visual Studio, you first need to install the Wix Extension for Visual Studio. Once the extension is installed, you can open a project in Visual Studio and start creating your website. To create a website using a Wix template, first select the template that you want to use.


2 Answers

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' /> 
like image 182
thijs Avatar answered Oct 10 '22 04:10

thijs


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

like image 41
johnburns320 Avatar answered Oct 10 '22 04:10

johnburns320