2008-10-02 13 views

Respuesta

22

Utilizamos esta:

Primero determine el directorio raíz .NET Framework desde el registro:

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

Entonces, dentro del componente que se instala su sitio web en 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> 

Para un instalador x64 (ESTO ES IMPORTANTE) Agregue Win64 = 'sí' a la búsqueda del registro, porque los 32 bits ambiente en una máquina de 64 bits de tiene una colmena diferente registro (y una frameworkroot diferente)

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

wow. muy facil. ¡Gracias! –

+0

@thjis: ¿Por qué solo registra esas tres extensiones? ¿Debería registrar también, por ejemplo, extensiones aspx y asmx? ¿Debería seguir adelante y registrar todas las extensiones enumeradas en IIS solo para estar seguro? – Ian

+0

@ian: solo los necesitamos, puede registrar todas las extensiones que necesite. – thijs

0
  • Primero encuentre la carpeta de la versión .NET correcta. Use DirectorySearch/FileSearch para realizar búsquedas.

  • Utilice la ruta anterior para llamar a aspnet_regiis.exe y configure la versión para la aplicación web a partir de una acción personalizada.

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

+0

El "1" en esa ruta es problemático. Es un identificador de sitio. Si tiene más de un sitio web en la instalación de IIS, entonces el sitio que desea puede tener un número diferente, y si es así, este comando no lo afectará, sino que alterará un sitio no relacionado en su lugar. Más detalles en Más detalles en 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

1

he encontrado una manera diferente utilizando la WiX WebApplicationExtension. Puede consultar la solución completa here y here.

Me gusta Wix hasta ahora, pero se necesita mucha investigación para encontrar lo que está buscando.

+0

Probé este enfoque con mi aplicación MVC y simplemente no funcionaba nada bien. Usar aspnet_regiis dentro de CustomAction para cambiar la AppPool a .NET 2.0 funcionó para mí (ver la respuesta de John Burns). – Jason

13

Esto es lo que funcionó para mí después de luchar con ella:

<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] y [dirVirtual] son propiedades que tiene que definir usted mismo. [VIRTUALDIR] solo es necesario si está configurando la versión de ASP.NET para una aplicación en lugar de un sitio web completo.

La secuenciación de la acción personalizada es crítica. Ejecutarlo antes de InstallFinalize hará que falle porque la aplicación web no estará disponible hasta después de eso.

Gracias a Chris Burrows para un ejemplo apropiado de encontrar el ejecutable aspnet_regiis (Google "Uso de WIX para Asegurar una cadena de conexión").

jb

+1

Gracias amigo, en mi opinión, esta es la respuesta más consistente aquí. Probé la otra sugerencia (que deja el grupo de aplicaciones como .NET 1.1) y fue demasiado complicada y no funcionó en mi aplicación MVC. Un punto, tuve que usar el atributo LongName para FileSearch (en lugar de Name, que se quejó solo admite el formato 8.3). Gracias de nuevo. – Jason

+0

Disculpe, ¿qué sería ExeCommand para configurarlo para todo el sitio web? –

+0

Además, ¿correspondería [WEBSITEID] a ? –

5

No se olvide de activar ASP 2.0 en el servidor

<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

+0

¿dónde hace referencia a ese Id luego? – BozoJoe

+0

En ninguna parte, la etiqueta "iis: WebServiceExtension" está dentro de una etiqueta de componente. Así es como se hace referencia. El Id no se usa en ningún otro lugar. – uli78

3

Mi respuesta es básicamente el mismo que los demás se ven aquí; Solo quería ofrecerle a la gente otro ejemplo.

Dado el número de extensiones de archivo que maneja ASP.NET, y que la lista cambia en cada versión, creo que la solución más confiable es ejecutar aspnet_regiis al final de la instalación. Esto no significa, sin embargo, que no tengo ningún tipo de apoyo para la restitución o desinstalación.Estoy creando una nueva aplicación en IIS, realmente no importa porque Wix lo borrará. Si está modificando una aplicación existente, quizás pueda averiguar en el registro qué versión de ASP.NET está configurada y ejecutar esa versión en aspnet_regiis para deshacer los cambios.

Lo siguiente usa 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

Esto es un poco más simple. No sé si esto funciona al actualizar un AppPool existente, pero funciona para crear un grupo de aplicaciones y configurar la versión .NET.

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

Intente que en Windows Server 2003 para establecer .NET 4, encontrará que ASP.NET se queda en la versión 2.0. Es necesario establecer la configuración del directorio virtual en la versión superior cuando el sitio web predeterminado o la configuración del servidor son más bajos. Tal vez sea un error en WIX, que no vuelva a correlacionar la configuración de la versión .NET de la agrupación de aplicaciones (que solo existe en las versiones más nuevas de IIS) con la configuración del directorio virtual en versiones anteriores. –

+0

La comprobación de la documentación muestra que la configuración solo es compatible con IIS 7 o superior. La segunda mejor opción para mí es ejecutar aspnet_regiis como una acción personalizada para versiones anteriores (ver otras respuestas aquí). Por lo tanto, solo puede usar eso si está seguro de que todos sus clientes/usuarios tienen Windows 2008/Vista o superior. –

Cuestiones relacionadas