【问题标题】:NSIS Installer (Unicode) writes in XML file instead of "<" "&lt;"NSIS 安装程序 (Unicode) 写入 XML 文件而不是 "<" "<"
【发布时间】:2015-10-27 08:36:36
【问题描述】:

我的 NSIS 脚本有点问题。我尝试修改配置文件中的连接字符串。

我用正确的插件尝试了 NSIS(ANSII 和 Unicode)的两个编译器。在这两种情况下,XML 文件中的不是“”而是两个“<” (在 & 和 l 之间没有空格)。

我使用 nsisXML 作为插件。

这是我的代码,我试过了:

nsisXML::create
nsisXML::load "$INSTDIR\InvoiceConfigurator.exe.config"
nsisXML::select '/configuration/connectionStrings'
IntCmp $2 0 notFound
nsisXML::setText '<add name="InvoiceConfigurator.Properties.Settings.mdis_dbConnectionString" connectionString="Data Source=$DataBaseInstance;Initial Catalog=$DataBaseName;User ID=$DataBaseUser;Password=$DataBasePw;" providerName="System.Data.SqlClient" />'
nsisXML::save "$INSTDIR\InvoiceConfigurator.exe.config"
Goto end
notFound:
DetailPrint "InvoiceConfigurator.exe.config has not been adjusted!"
end:

DetailPrint 中的消息未显示!

【问题讨论】:

    标签: xml unicode installation nsis


    【解决方案1】:

    因此,插件主页 (http://wiz0u.free.fr/prog/nsisXML/) 此工具无法像 JavaScript 那样将子节点插入为文本。 您应该手动插入每个节点和属性。像这样的:

    nsisXML::create
    nsisXML::load "$INSTDIR\InvoiceConfigurator.exe.config"
    nsisXML::select '/configuration/connectionStrings'
    IntCmp $2 0 notFound
    nsisXML::createElement "add"
    nsisXML::setAttribute "name" "InvoiceConfigurator.Properties.Settings.mdis_dbConnectionString"
    nsisXML::setAttribute "connectionString" "Data Source=$DataBaseInstance;Initial Catalog=$DataBaseName;User ID=$DataBaseUser;Password=$DataBasePw;"
    nsisXML::setAttribute "providerName" "System.Data.SqlClient"
    nsisXML::appendChild
    nsisXML::save "$INSTDIR\InvoiceConfigurator.exe.config"
    Goto end
    notFound:
    DetailPrint "InvoiceConfigurator.exe.config has not been adjusted!"
    end:
    

    【讨论】:

    • 感谢 Serge 的回答,我会尽快尝试!
    猜你喜欢
    • 2015-11-11
    • 1970-01-01
    • 2021-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多