2008-10-02 56 views

回答

22

我们使用这样的:

首先确定从注册表中的.Net框架的根目录:

<Property Id="FRAMEWORKROOT"> 
    <RegistrySearch Id="FrameworkRootDir" Root="HKLM" 
       Key="SOFTWARE\Microsoft\.NETFramework" 
       Type="directory" Name="InstallRoot" /> 
</Property> 

然后,安装您的网站在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> 

对于x64安装程序(这是重要的) 将Win64 ='yes'添加到注册表搜索,因为32位在64位机器上的环境中有不同的注册表配置单元(和不同的frameworkroot)

<RegistrySearch Id="FrameworkRootDir" Root="HKLM" 
     Key="SOFTWARE\Microsoft\.NETFramework" 
     Type="directory" 
     Name="InstallRoot" Win64='yes' /> 
+1

哇。 supereasy。谢谢! – 2009-12-02 03:49:53

+0

@thjis:你为什么只注册这三个扩展名?你是否还应该注册aspx和asmx扩展名?你是否应该继续注册IIS中列出的所有扩展名以确保其安全? – Ian 2010-09-29 07:14:27

+0

@ian:我们只需要那些,你可以注册你需要的所有扩展。 – thijs 2010-11-05 14:21:03

0
  • 首先找到正确的.NET版本文件夹。使用DirectorySearch/FileSearch执行搜索。

  • 使用上述路径调用aspnet_regiis.exe并从自定义操作设置webapp的版本。

    aspnet_regiis.exe -s W3SVC/1/ROOT/SampleApp1

+0

该路径中的“1”是有问题的。这是一个网站标识符。如果您在IIS安装上有多个网站,那么您需要的站点可能会有不同的编号,如果是这样,那么这个命令不会影响它,但会改变一个不相关的站点。有关更多详细信息,请访问http://weblogs.asp.net/owscott/archive/2006/05/30/ASPNet_5F00_regiis.exe-tool_2C00_-setting-the-default-version-without-forcing-an-upgrade-on- all-sites.aspx – Anthony 2012-02-27 22:39:46

1

我使用WiX的WebApplicationExtension发现了一个不同的方式。您可以查看完整解决方案herehere

我喜欢Wix到目前为止,但是男人需要大量的挖掘才能找到你要找的东西。

+0

我用我的MVC应用程序试过这种方法,它根本不会很好地播放。在CustomAction中使用aspnet_regiis将AppPool更改为.NET 2.0可以为我工作(请参阅John Burns的答案)。 – Jason 2009-08-14 11:54:52

13

这里是我与它搏斗后什么工作:

<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]和[VIRTUALDIR]是你必须定义自己的属性。 [VIRTUALDIR]仅在您为应用程序而不是整个网站设置ASP.NET版本时才有必要。

自定义操作的顺序很关键。在InstallFinalize之前执行它会导致它失败,因为直到那之后Web应用程序才可用。

感谢Chris Burrows寻找aspnet_regiis可执行文件的正确示例(Google“使用WIX保护连接字符串”)。

JB

5

不要忘了在服务器上启用ASP 2.0

<iis:WebServiceExtension Id="ExtensionASP2" Group="ASP.NET v2.0.50727" Allow="yes" File="[NETFRAMEWORK20INSTALLROOTDIR]aspnet_isapi.dll" Description="ASP.NET v2.0.50727"/> 

Here is the sof-question

3

我的回答是基本相同,别人在这里看到;我只是想给人们提供另一个例子。

鉴于ASP.NET处理的文件扩展名的数量,并且列表在每个版本中都有所变化,我认为最可靠的解决方案是在安装结束时运行aspnet_regiis。这确实意味着,但我没有任何支持回滚或卸载。我在IIS中创建一个新的应用程序,它并不重要,因为它将被Wix删除。如果您正在修改现有的应用程序,也许您可​​以从注册表中找到配置了哪个版本的ASP.NET,然后运行该版本的aspnet_regiis以撤销您的更改。

以下使用Wix 3.5。

<Fragment> 
    <!-- Use the properties in Wix instead of doing your own registry search. --> 
    <PropertyRef Id="IISMAJORVERSION"/> 
    <PropertyRef Id="NETFRAMEWORK40FULL"/> 
    <PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR"/> 

    <!-- The code I'm using is intended for IIS6 and above, and it needs .NET 4 to be 
    installed. --> 
    <Condition Message="This application requires the .NET Framework 4.0. Please install the required version of the .NET Framework, then run this installer again."> 
     <![CDATA[Installed OR (NETFRAMEWORK40FULL)]]> 
    </Condition> 
    <Condition Message="This application requires Windows Server 2003 and Internet Information Services 6.0 or better."> 
     <![CDATA[Installed OR (VersionNT >= 502)]]> 
    </Condition> 

    <!-- Populates the command line for CAQuietExec. IISWEBSITEID and IISVDIRNAME 
    could be set to default values, passed in by the user, or set in your installer's 
    UI. --> 
    <CustomAction Id="ConfigureIis60AspNetCommand" Property="ConfigureIis60AspNet" 
        Execute="immediate" 
        Value="&quot;[NETFRAMEWORK40FULLINSTALLROOTDIR]aspnet_regiis.exe&quot; -norestart -s &quot;W3SVC/[IISWEBSITEID]/ROOT/[IISVDIRNAME]&quot;" /> 
    <CustomAction Id="ConfigureIis60AspNet" BinaryKey="WixCA" DllEntry="CAQuietExec" 
        Execute="deferred" Return="check" Impersonate="no"/> 
    <InstallExecuteSequence> 
     <Custom Action="ConfigureIis60AspNetCommand" After="CostFinalize"/> 

     <!-- Runs the aspnet_regiis command immediately after Wix configures IIS. 
     The condition shown here assumes you have a selectable feature in your 
     installer with the ID "WebAppFeature" that contains your web components. The 
     command will not be run if that feature is not being installed, or if IIS is 
     not version 6. It *will* run if the application is being repaired. 

     SKIPCONFIGUREIIS is a property defined by Wix that causes it to skip the IIS 
     configuration. --> 
     <Custom Action="ConfigureIis60AspNet" After="ConfigureIIs" Overridable="yes"> 
      <![CDATA[((&WebAppFeature = 3) OR (REINSTALL AND (!WebAppFeature = 3))) 
      AND (NOT SKIPCONFIGUREIIS) AND (IISMAJORVERSION = "#6")]]> 
     </Custom> 
    </InstallExecuteSequence> 
    <UI> 
     <ProgressText Action="ConfigureIis60AspNetCommand" 
      >Configuring ASP.NET</ProgressText> 
     <ProgressText Action="ConfigureIis60AspNet" 
      >Configuring ASP.NET</ProgressText> 
    </UI> 

</Fragment> 
3

这有点简单。我不知道这是否适用于更新现有AppPool,但适用于创建APP池并设置.NET版本。

<iis:WebServiceExtension Id="AMS_AppPool" Name="AccountManagementSVC1" Identity="other" ManagedPipelineMode="integrated" ManagedRuntimeVersion="v4.0" User="AMS_AppPoolUser" RecycleMinutes="120" />