我的NSIS脚本有点问题。我尝试修改配置文件中的connectionString。
我尝试使用正确的插件从NSIS(ANSII和Unicode)编译两个..在XML文件中的两种情况都不是“<”或“>”但两个“& lt;” (没有&和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:
详细信息中的消息未显示!
答案 0 :(得分: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: