WIX:如何在现有的Web应用程序或站点上注册新的ISAPI扩展或脚本映射? [英] WIX: How can I register a new ISAPI Extension or Script Map on an existing Web App or Site?

查看:115
本文介绍了WIX:如何在现有的Web应用程序或站点上注册新的ISAPI扩展或脚本映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了 WebApplicationExtension 元素,但是因为它必须是 WebApplication 的子级,它似乎需要创建一个新的WebApplication.我不要

I've seen the WebApplicationExtension element, but because it must be a child of WebApplication, it appears to require the creation of a new WebApplication. I don't want that.

我想在现有网站上创建扩展名(或脚本映射).卸载后,该网站应保留,但应删除扩展名(脚本映射项).

I want to create the extension (or script map) on an existing website. On uninstall, the website should remain but the extension (script map entry) should be removed.

有人知道如何在WIX中做到这一点吗?

Anyone know how to do this in WIX?

如果我没有很好的答案,我想我将不得不在InstallFinalize之前的脚本中完成此操作.

If I get no good answers, I guess I will have to do it within script before InstallFinalize.

推荐答案

我无法在WIX中找到实现此目的的方法,因此我采用了自定义操作.我一直在用Javascript编写所有自定义操作.我发现Java脚本易于使用且功能强大,尽管别人说了什么.

I couldn't figure out a way to do this in WIX, so I resorted to a custom action. I had been writing all my custom actions in Javascript. I find Javascript to be easy to use and robust for that purpose, despite what others have said.

但是我找不到从Javascript添加脚本映射的方法,因为IIS元数据库更新需要使用VBArray数据类型,VBScript支持此数据类型,而Javascript不支持.哎呀

But I could not find a way to add a scriptmap from Javascript, because the IIS metabase update requires the use of a VBArray datatype, which is supported in VBScript, but not in Javascript. Whoops.

因此,这是VBScript中的代码.

So, here is the code, in VBScript.

Function AddExtension_CA()

    VBSLogMessage("AddExtension_CA() ENTRY")
    Dim iis
    Set iis = GetObject("winmgmts://localhost/root/MicrosoftIISv2")

    dim siteName
    siteName = Session.Property("WEBSITE_NAME")

    VBSLogMessage "website name(" & siteName & ")"

    If (siteName <> "") Then
        Dim idir, dll
        idir = Session.Property("INSTALLDIR")
        dll = idir & "\MyIsapiExtension.dll"

        Dim query
        If (siteName <> "W3SVC") Then
            query = "SELECT * FROM IIsWebServerSetting WHERE Name = '" & siteName & "'"
        Else
            query = "SELECT * FROM IIsWebServiceSetting"
        End If

        Set results = iis.ExecQuery(query)
        Dim newMaps()   '' dynamically-sized Array

        '' two passes
        For t = 0 to 1
            Dim c
            c=0
            For Each item in results
                '' in pass 1, count them. 
                '' in pass 2, copy them.
                For i = 0 to Ubound(item.ScriptMaps)
                    If UCase(item.ScriptMaps(i).Extensions) <> ".IIRF" Then
                        If t = 1 Then
                            Set newMaps(c) = item.ScriptMaps(i)
                        End if
                        c = c+1
                    End If
                Next

                If t = 0 Then
                    ReDim Preserve newMaps(c)
                Else
                    VBSLogMessage("setting new filter")

                    Set newMaps(c) = iis.get("ScriptMap").SpawnInstance_()
                    newMaps(c).Extensions = ".iirf"
                    newMaps(c).ScriptProcessor= dll
                    newMaps(c).Flags = "1"
                    newMaps(c).IncludedVerbs = "GET,POST"
                    item.ScriptMaps = newMaps
                    item.Put_()
                End If
            Next
        Next

        VBSLogMessage("Allowing the DLL as an Extension")

        dim IIsWebServiceObj
        Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")
        IIsWebServiceObj.AddExtensionFile dll, True, "GroupId", True, "Description of the Extension"
        Set IIsWebServiceObj = Nothing

    End If

    Set iis = Nothing

    VBSLogMessage("AddExtension_CA() EXIT")

    AddExtension_CA = 1   ' MsiActionStatus.Ok

End Function

这是WIX代码:

<Fragment>
    <CustomAction Id="CA.AddExtension"
              BinaryKey="B.VBScript"
              VBScriptCall="AddExtension_CA"
              Execute="immediate"
              Return="check" />

    ....

另请参阅:
AddExtensionFile .

See also:
AddExtensionFile.

这篇关于WIX:如何在现有的Web应用程序或站点上注册新的ISAPI扩展或脚本映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆