如何使用Wix在IIS 7上安装ASP.Net MVC应用程序?

时间:2021-03-31 03:35:16

For IIS6 I can use the IIS helpers in Wix to install a web application like this:

对于IIS6,我可以使用Wix中的IIS帮助程序来安装这样的Web应用程序:

<iis:WebAppPool 
    Id="AP_MyApp" 
    Name="My Application Pool" 
    Identity="networkService" />
<iis:WebApplication 
    Id="WA_MyApp" 
    Name="MyApp" 
    WebAppPool="AP_MyApp">
    <iis:WebApplicationExtension
        CheckPath="no"
        Executable="[NETFRAMEWORK20INSTALLROOTDIR]aspnet_isapi.dll"
        Verbs="GET,HEAD,POST"/>
</iis:WebApplication>

Unfortunately, this doesn't work for IIS7. We don't want to use the aspnet_isapi.dll mechanism, and instead want the integrated pipeline to handle the request routing. The app pool created by this script is in Classic mode not Integrated mode so none of the handlers get run correctly.

不幸的是,这对IIS7不起作用。我们不想使用aspnet_isapi.dll机制,而是希望集成管道处理请求路由。此脚本创建的应用程序池处于经典模式而非集成模式,因此没有任何处理程序可以正常运行。

How can I correctly install an MVC app on IIS 7?

如何在IIS 7上正确安装MVC应用程序?

3 个解决方案

#1


2  

The IIS extensions for WIX don't support IIS7. The IIS team keep rewriting the metabase between versions. There are quite a few things that don't work, the lack of an integrated app pool amongst them.

WIX的IIS扩展不支持IIS7。 IIS团队不断重写版本之间的元数据库。有很多东西不起作用,缺少一个集成的应用程序池。

Until the extensions get rewritten, you're left with three options:

在扩展被重写之前,你有三个选择:

  • Use build in custom actions to invoke appcmd.exe
  • 使用内置自定义操作来调用appcmd.exe
  • Use XmlConfig to update applicationHost.config
  • 使用XmlConfig更新applicationHost.config
  • Write your own custom actions
  • 编写自己的自定义操作

I've opted for the xmlconfig option at the moment as you can do this within a component and tie it to a feature.

我现在选择了xmlconfig选项,因为您可以在组件中执行此操作并将其绑定到功能。

#2


11  

I personally recommend using AppCmd.exe (matthewthurlow's first bullet) because you don't have to count on the legacy management components being installed, or risk modifying the configuration XML manually.

我个人建议使用AppCmd.exe(matthewthurlow的第一个项目符号),因为您不必依赖正在安装的旧管理组件,也不必冒险手动修改配置XML。

If you are not comfortable with AppCmd, Mike Volodarsky has a great article on Getting Started with AppCmd.exe, and the Microsoft IIS Configuration Reference is excellent, offering UI, Code and AppCmd examples for modifying each of the configuration items (e.g. Application Pools ). The IIS7 Administration Pack also includes a Configuration Editor that allows you to generate AppCmd scripts from any existing configuration.

如果您对AppCmd不满意,Mike Volodarsky有一篇关于AppCmd.exe入门的精彩文章,并且Microsoft IIS配置参考非常好,提供了用于修改每个配置项的UI,代码和AppCmd示例(例如应用程序池) 。 IIS7管理包还包括一个配置编辑器,允许您从任何现有配置生成AppCmd脚本。

To integrate AppCmd into WiX, you need to create and schedule two custom actions for each command. There is general information in the WiX v3 manual documenting this procedure, and I've included a concrete example below.

要将AppCmd集成到WiX中,您需要为每个命令创建和安排两个自定义操作。 WiX v3手册中有一般信息记录了这个程序,我在下面列举了一个具体的例子。

First, you need to set up an immediate action to store the command line in a property:

首先,您需要设置立即操作以将命令行存储在属性中:

<CustomAction 
  Id="CreateAppPool_Cmd" 
  Property="CreateAppPool" 
  Execute="immediate" 
  Value="&quot;[WindowsFolder]system32\inetsrv\APPCMD.EXE&quot; add apppool /name:&quot;[APP_POOL_NAME]&quot;" /> 

Next you set up a deferred action which references this property:

接下来,设置引用此属性的延迟操作:

<CustomAction 
  Id="CreateAppPool" 
  BinaryKey="WixCA" 
  DllEntry="CAQuietExec" 
  Execute="deferred" 
  Return="ignore" 
  Impersonate="no"/> 

And finally, you need to schedule these. The immediate action that sets the properties seem to work well after InstallFinalize, and the deferred action works after InstallFiles. I haven't got as far as figuring out rollback actions yet.

最后,你需要安排这些。设置属性的立即操作似乎在InstallFinalize之后运行良好,并且延迟操作在InstallFiles之后有效。我还没有找到回滚行动。

MapGuide Open Source does this method extensively; you can see the CA scheduling in our MapGuide.wxs file, and the CA definition in our IIS7.wxs file.

MapGuide Open Source广泛使用这种方法;您可以在我们的MapGuide.wxs文件中看到CA计划,在IIS7.wxs文件中看到CA定义。

#3


4  

Thanks to @matthewthurlow, I was able to use the XML utils to achieve what I needed to do:

感谢@matthewthurlow,我能够使用XML utils来实现我需要做的事情:

<util:XmlFile 
    Id="ModifyAppPoolPipelineType"
    Action="setValue"
    ElementPath="//configuration/system.applicationHost/applicationPools/add[\[]@name='My Application Pool'[\]]/@managedPipelineMode"
    File="[WindowsFolder]System32\inetsrv\config\applicationHost.config"
    Value="Integrated"/>

The rest of the actions do seem to work fine with IIS 7.

其余的操作似乎在IIS 7中运行良好。

#1


2  

The IIS extensions for WIX don't support IIS7. The IIS team keep rewriting the metabase between versions. There are quite a few things that don't work, the lack of an integrated app pool amongst them.

WIX的IIS扩展不支持IIS7。 IIS团队不断重写版本之间的元数据库。有很多东西不起作用,缺少一个集成的应用程序池。

Until the extensions get rewritten, you're left with three options:

在扩展被重写之前,你有三个选择:

  • Use build in custom actions to invoke appcmd.exe
  • 使用内置自定义操作来调用appcmd.exe
  • Use XmlConfig to update applicationHost.config
  • 使用XmlConfig更新applicationHost.config
  • Write your own custom actions
  • 编写自己的自定义操作

I've opted for the xmlconfig option at the moment as you can do this within a component and tie it to a feature.

我现在选择了xmlconfig选项,因为您可以在组件中执行此操作并将其绑定到功能。

#2


11  

I personally recommend using AppCmd.exe (matthewthurlow's first bullet) because you don't have to count on the legacy management components being installed, or risk modifying the configuration XML manually.

我个人建议使用AppCmd.exe(matthewthurlow的第一个项目符号),因为您不必依赖正在安装的旧管理组件,也不必冒险手动修改配置XML。

If you are not comfortable with AppCmd, Mike Volodarsky has a great article on Getting Started with AppCmd.exe, and the Microsoft IIS Configuration Reference is excellent, offering UI, Code and AppCmd examples for modifying each of the configuration items (e.g. Application Pools ). The IIS7 Administration Pack also includes a Configuration Editor that allows you to generate AppCmd scripts from any existing configuration.

如果您对AppCmd不满意,Mike Volodarsky有一篇关于AppCmd.exe入门的精彩文章,并且Microsoft IIS配置参考非常好,提供了用于修改每个配置项的UI,代码和AppCmd示例(例如应用程序池) 。 IIS7管理包还包括一个配置编辑器,允许您从任何现有配置生成AppCmd脚本。

To integrate AppCmd into WiX, you need to create and schedule two custom actions for each command. There is general information in the WiX v3 manual documenting this procedure, and I've included a concrete example below.

要将AppCmd集成到WiX中,您需要为每个命令创建和安排两个自定义操作。 WiX v3手册中有一般信息记录了这个程序,我在下面列举了一个具体的例子。

First, you need to set up an immediate action to store the command line in a property:

首先,您需要设置立即操作以将命令行存储在属性中:

<CustomAction 
  Id="CreateAppPool_Cmd" 
  Property="CreateAppPool" 
  Execute="immediate" 
  Value="&quot;[WindowsFolder]system32\inetsrv\APPCMD.EXE&quot; add apppool /name:&quot;[APP_POOL_NAME]&quot;" /> 

Next you set up a deferred action which references this property:

接下来,设置引用此属性的延迟操作:

<CustomAction 
  Id="CreateAppPool" 
  BinaryKey="WixCA" 
  DllEntry="CAQuietExec" 
  Execute="deferred" 
  Return="ignore" 
  Impersonate="no"/> 

And finally, you need to schedule these. The immediate action that sets the properties seem to work well after InstallFinalize, and the deferred action works after InstallFiles. I haven't got as far as figuring out rollback actions yet.

最后,你需要安排这些。设置属性的立即操作似乎在InstallFinalize之后运行良好,并且延迟操作在InstallFiles之后有效。我还没有找到回滚行动。

MapGuide Open Source does this method extensively; you can see the CA scheduling in our MapGuide.wxs file, and the CA definition in our IIS7.wxs file.

MapGuide Open Source广泛使用这种方法;您可以在我们的MapGuide.wxs文件中看到CA计划,在IIS7.wxs文件中看到CA定义。

#3


4  

Thanks to @matthewthurlow, I was able to use the XML utils to achieve what I needed to do:

感谢@matthewthurlow,我能够使用XML utils来实现我需要做的事情:

<util:XmlFile 
    Id="ModifyAppPoolPipelineType"
    Action="setValue"
    ElementPath="//configuration/system.applicationHost/applicationPools/add[\[]@name='My Application Pool'[\]]/@managedPipelineMode"
    File="[WindowsFolder]System32\inetsrv\config\applicationHost.config"
    Value="Integrated"/>

The rest of the actions do seem to work fine with IIS 7.

其余的操作似乎在IIS 7中运行良好。