使用Wixtoolset更改App.config中的connectionString Log4Net

时间:2018-08-12 15:43:55

标签: .net app-config wix3.6 log4net-appender

我在app.config中有下一段代码。

<log4net>
  <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <bufferSize value="1" />
    <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <connectionString value="data source=serverx;initial catalog=dbx;integrated security=false;persist security info=True;User ID=sa;Password=x" />
    <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
    <parameter>
      <parameterName value="@log_date" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.RawTimeStampLayout" />
    </parameter>
....

我的wix代码块替换connectionString:

<Property Id="CNN_SERVER" Value="MYSERVER"/>
<Property Id="CNN_DATABASE" Value="MYDATABASE"/>
<Property Id="CNN_PASSWORD" Value="MYPWD"/>


<util:XmlFile
      Id="UpdateLog4NetConnectionString"
      Action="setValue"
      File="[INSTALLFOLDER]testConfig.exe.config"
      SelectionLanguage="XPath"
      Permanent="yes"
      ElementPath="/configuration/log4Net/appender/[\[]@name='AdoNetAppender'[\]]/@connectionString"
      Name ="value"
      Value="data source=[CNN_SERVER];intial catalog=[CNN_DATABASE];integrated security=false;persist security info=True;User Id=sa; Password=[CNN_PASSWORD];" />

在运行msi安装程序时,我收到了下一条消息。

无法找到节点: / configuration / log4Net / appender / [@ name ='AdoNetAppender'] / @ connectionString in XML fil:C:\ Program Files(x86)\ testInstaller \ testConfig.exe.config,系统错误:-2147467259

感谢您的帮助。

0 个答案:

没有答案