0

我有一个 NLog.config,我必须指向另一个用于生产的数据库。我正在使用这个 工具来改造它。这是我的 NLog.Config 的一部分。

<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
  <target name="ExceptionLog" type="Database">
    <connectionString>
       ---- Db Connection string for test-------
    </connectionString>

我已经创建了生产转换,但是无法转换文件。

这是我所拥有的

<?xml version="1.0"?>
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <parameters value="Db connection for prod"
           xdt:Transform="Replace"  xdt:Locator="XPath(targets/target/connectionString)"  />
</configuration>

我们需要改变整个元素而不是属性。

4

1 回答 1

1

成功添加“nlog”xdt 命名空间别名:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" 
               xmlns:nlog="http://www.nlog-project.org/schemas/NLog.xsd">

  <nlog:connectionString xdt:Transform="Replace"
        xdt:Locator="XPath(/nlog:nlog/nlog:targets/nlog:target/nlog:connectionString)">
    ....put-connection-string-here....
  </nlog:connectionString>

</configuration>
于 2017-09-27T09:56:00.503 回答