2008-10-02 53 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" />