1

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.

Anyone know how to do this in WIX?


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

4

1 回答 1

1

我想不出在 WIX 中执行此操作的方法,因此我采用了自定义操作。我一直在用 Javascript 编写我的所有自定义操作尽管其他人说了什么,但我发现 Javascript 易于使用且功能强大。

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

所以,这里是 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

于 2010-02-05T15:02:00.053 回答