如何通过 WiX 3.5 检查 IIS 7 网站是否存在?
注意:这个问题也可以在 上找到WiX 邮件列表。
我需要能够根据网站的描述检查 IIS7 网站是否存在。如果该网站不存在,我需要取消安装。如果该网站存在,我想继续安装。我还需要能够保存网站的站点 ID,以便我可以在卸载期间使用它。
出于调试目的,我对网站的描述进行了硬编码。我没有看到任何迹象表明正在 MSI 日志文件中对网站进行检查。这是我正在使用的代码:
<iis:WebSite Id="IISWEBSITE" Description="Default Web Site" SiteId="*">
<iis:WebAddress Id="IisWebAddress" Port="1"/>
</iis:WebSite>
<Condition Message="Website [IISWEBSITE] not found.">
<![CDATA[IISWEBSITE]]>
</Condition>
使用 ORCA 我可以看到 IIsWebAddress 和 IIsWebSite 表已添加到 MSI 中。这些值为:
IIsWebsite
WEB: IISWEBSITE
Description: Default Web Site
KeyAddress: IisWebAddress
Id: -1
IIsWebAddress
Address: IisWebAddress
Web_: IISWEBSITE
Port: 1
Secure: 0
使用上述代码,安装将停止,并显示错误消息“找不到网站”。看来 IISWEBSITE 永远不会被设置。不过,我知道“默认网站”的存在。我知道我一定错过了一些东西,但是什么呢?
如何在 IIS 7 中执行简单的网站检查是否存在?
Note: This question can also be found on the WiX mailing list.
I need to be able to check for the existence of an IIS7 website based on the website's description. If the website does not exist I need to cancel the installation. If the website exists I want to continue the installation. I also need to be able to save the site id of the website so that I may use it during an uninstall.
For debugging purposes I have hard coded the website's description. I do not see any indication that a check for the website is being made within the MSI log file. This is the code I am using:
<iis:WebSite Id="IISWEBSITE" Description="Default Web Site" SiteId="*">
<iis:WebAddress Id="IisWebAddress" Port="1"/>
</iis:WebSite>
<Condition Message="Website [IISWEBSITE] not found.">
<![CDATA[IISWEBSITE]]>
</Condition>
Using ORCA I can see that IIsWebAddress and IIsWebSite tables are added to the MSI. The values are:
IIsWebsite
WEB: IISWEBSITE
Description: Default Web Site
KeyAddress: IisWebAddress
Id: -1
IIsWebAddress
Address: IisWebAddress
Web_: IISWEBSITE
Port: 1
Secure: 0
With the above code, the installation is halted with the error message "Website not found". It appears that IISWEBSITE is never getting set. Though, I know that "Default Web Site" exists. I know that I must be missing something, but what?
How can I perform a simple check for the existence of a website in IIS 7?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的问题。
我编写了一个自定义操作来从注册表检查 IIS 的版本。
根据注册表值创建虚拟目录
I too had same problem.
I wrote a custom action to check the version of IIS from registry.
On the basis of registry value create virtual directory
我用 Javascript 编写了一个自定义操作来执行此操作。如果您使用的是 IIS7,那么您可以使用 appcmd.exe 工具,只需从 Javascript 中调用它即可获取站点列表。理论上来说,做起来非常简单。但在实践中,你需要跨越一堆障碍。
这是我想出的:
I wrote a custom action in Javascript to do this. If you are assuming IIS7, then you can use the appcmd.exe tool, and just invoke it from within Javascript to get the list of sites. In theory, it's pretty simple to do. But in practice, there's a bunch of hoops you need to jump through.
Here's what I came up with: