如何使用WixSharp安装网站并关联AppPool
我正在尝试查找如何使用 WixSharp (WiX 的托管代码接口)进行安装的示例一个网站并关联一个应用程序池。
我想要实现的步骤是:
- 如果该网站存在于 IIS 6 中,则将其删除。
- 如果 IIS 6 中存在 AppPool,请将其删除。
- 从目标目录中删除应用程序工件。
- 将新的应用程序工件复制到目标目录。
- 创建应用程序池。
- 创建网站,并将其链接到应用程序池。
我已经在 MSBuild 中实现了这一点,但这不如 MSI 有用。因此我试图用 WixSharp 语法“重写”上面的内容。
WixSharp 显然支持 WIXIISExtension,但 Google 尚未提供任何示例。
我如何在 WixSharp 中编写上述代码?
I am trying to find examples of how to use WixSharp (managed code interface to WiX) to install a website and associate an AppPool.
The steps I want to achieve are:
- If the website exists in IIS 6, delete it.
- If the AppPool exists in IIS 6, delete it.
- Delete the application artifacts from the destination directory.
- Copy the new application artifacts to the destination directory.
- Create the AppPool.
- Create the Website, linking it to the AppPool.
I have achieved this in MSBuild but that is not as useful as an MSI. Hence I am trying to "rewrite" the above in WixSharp syntax.
WixSharp apparently supports WIXIISExtension but Google has not yielded any examples yet.
How would I code the above in WixSharp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好问题。
我在当前的项目中使用 WixSharp,我对此非常满意。令人惊奇的是,您可以通过使用 C# 语法来避免编写 XML 文件。顺便说一句,我不认为你在重新发明轮子......你是在用 WixSharp 加速轮子。
由于 WixSharp 版本 1.9.6 不提供创建具有关联 WebAppPool 的网站,因此我通过创建 CustomWebSite.cs 文件来完成此操作。通过这种方式,我使用以下代码创建了我的 Web 应用程序:
这是我的 CustomWebSite.cs 文件,我只用它来创建一个网站,我相信它会更好:
您还可以使用其他方法来解决您的问题,通过生成WIX xml 文件遵循 网站定义,并按照指示使用 XML 注入在 WixSharp带有 XMLInjection 的 IIS 示例,您可以在其中订阅 WixSourceGenerate 事件。
请记住,WixSharp 生成 Wix XML 定义文件,您可以在 WixSourceGenerate 事件之后修改此 XML 文件。
Good question.
I am using WixSharp for my current project and I am really happy with it. It is awesome how you can avoid writing XML files by doing all with C# syntax. By the way, I don't think you are reinventing the wheel... you are speeding up the wheel with WixSharp.
As WixSharp version 1.9.6 doesn't provide creating a WebSite with an associated WebAppPool, I did it by creating a CustomWebSite.cs file. In this way, I created my Web Application using this code:
Here is my CustomWebSite.cs file that I only used to create one WebSite and I am sure it could be better:
You also have other way to solve your problem, by generating the WIX xml file following WebSite definitions and using XML injection as indicated in WixSharp IIS Sample with XMLInjection where you can subscribe to the WixSourceGenerated event.
Remember that WixSharp generates the Wix XML definitifion file, and you can modify this XML file after the WixSourceGenerated event.
我使用 WIX 也是出于同样的目的。我尝试部署的应用程序约为 300 MB,我需要为其创建虚拟目录、应用程序池等。
我认为您的要求是相同的。
我建议 WIX 对此非常有用。您可以让屏幕询问用户虚拟目录名称、应用程序池等。WIX
代码非常适合 IIS 5.1、6、7。对于 7.5,您需要创建一个自定义操作。因此,如果安装了 IIS 6 兼容模式,即使对于 IIS 7.5,您也可以使用 wix 创建虚拟目录。
到目前为止,我在使用 WIX 部署 Web 应用程序时还没有遇到任何错误。
I am using WIX for the same purpose. The application I am trying to deploy is around 300 MB and I need to create virtual directory for same, app pool, etc.
I think your requirement is same.
I would suggest WIX is really good for this. You can have screens asking user virtual directory name, Application Pool, etc.
WIX code works perfectly for IIS 5.1, 6, 7. For 7.5 you need to create a customaction. As such you can use wix to create virtual directory even for IIS 7.5 if IIS 6 compatibility mode is installed.
Uptill now I haven't faced any errors using WIX to deploy web applications.