WIX 安装程序从 XmlConfig 元素中删除条目 [英] WIX Installer remove entry from XmlConfig element

查看:26
本文介绍了WIX 安装程序从 XmlConfig 元素中删除条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除DrawListAddin"从此列表中使用 WIX XmlConfig ?

How to delete the "DrawListAddin" from this list with WIX XmlConfig ?

  <?xml version="1.0" encoding="utf-8"?>
  <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
    <string>ExplorerAddin</string>
    <string>DrawListAddin</string>
    <string>MyDataAddin</string>
  </ArrayOfString>

结果应该是这样的

  <?xml version="1.0" encoding="utf-8"?>
  <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
    <string>ExplorerAddin</string>
    <string>MyDataAddin</string>
  </ArrayOfString>

我尝试了多种设置但没有任何效果..最后一个版本看起来像这样.搜索正确的项目,然后将其删除.XML 文件被修改但没有变化.

i try multiple settings but nothing work .. the last version looks like this. Searching for the correct item and than remove it. The XML file gets modified but no changes.

<util:XmlConfig Id='XmlSettingsRemove' 
    On="install"
    File='[E3D31_INSTALL_DIR]DesignAddins.xml' 
    Node='element'
    Action='delete'                         
    VerifyPath="//*[\[]text() [\[]contains(.,'DrawListAddin')[\]][\]]" 
    ElementPath="//ArrayOfString" 
    Sequence='1' 
 />

此代码带来一个错误消息,指出无法找到节点,但/.."最后明确选择正确的父

this code bring an error message that the node could not be found but the "/.." at the end explicit selects the parent correct

<util:XmlConfig Id='XmlSettingsRemove' 
  On="install"
  File='[E3D31_INSTALL_DIR]DesignAddins.xml' 
  Node='element'
  Action='delete'                       
  VerifyPath="/ArrayOfString/string[\[]text()[\[]contains(.,'DrawListAddin')[\]][\]]" 
  ElementPath="/ArrayOfString/string[\[]text()[\[]contains(.,'DrawListAddin')[\]][\]]/.." 
  Sequence='1' 
    />

推荐答案

仅供参考 .. 这是带有嵌入式脚本的解决方案 .. 我在代码中放入了一些占位符,例如DO_SOME_HERE"..

just for review .. here is the solution with a embedded script .. i put some placeholder into the code like "DO_SOME_HERE" ..

    <CustomAction Id="UnInstallUIFileSetProperty" Property="UnInstallUIFileExec" Value="[PLACE_YOUR_PATH_TO_XML_FILE_HERE]" />  
    <CustomAction Id="UnInstallUIFileExec" Script="vbscript" Execute='deferred' Impersonate='no' Return='ignore'>
  <![CDATA[                     
                    on error resume next
                    c=Session.Property("CustomActionData")
                    n=c+"ADD_THE_XML_FILENAME_HERE"                                         
                    
                    Set x = CreateObject("Microsoft.XMLDOM")                                            
                    
                    x.async = False 
                    x.load(n)
                    
                    Set r = x.documentElement                       
                    Set l = r.getElementsByTagName("string")
                    For Each e In l                         
                        if InStr(e.text,"ENTER_SEARCHTEXT_HERE") then
                            e.ParentNode.removeChild(e)
                        end if
                    Next            
                    
                  if err.Number<>0 then
                    res=MsgBox("remove of addin failed: "+n)                        
                    else
                      x.Save(n)
                    end if
                
  ]]>
</CustomAction>

这篇关于WIX 安装程序从 XmlConfig 元素中删除条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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