Using this online tester it is easy to see the following issue
I have a web.config that looks like:
<?xml version="1.0"?>
<configuration>
  <nlog/>
</configuration>
And a transform that looks like:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/>
  <nlog xdt:Transform="Replace"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets async="true">
      <target name="LogMill" xsi:type="FallbackGroup" returnToFirstOnSuccess="true">
        <target xsi:type="LogMillMessageBus"/>
        <target xsi:type="File" fileName="..\LogMill-FailSafe.log" layout="${TextErrorLayout}"/>
      </target>
    </targets>
  </nlog>
</configuration>
But the output is not what I expect, it moves the xsi namespace declaration down to the element that uses it, which causes nlog to fail to parse the configuration with the error Parameter p4 not supported on FallbackGroupTarget
<?xml version="1.0"?>
<configuration>
  <nlog>
    <targets async="true">
      <target name="LogMill" p4:type="FallbackGroup" returnToFirstOnSuccess="true" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">
      <target p4:type="LogMillMessageBus" /><target p4:type="File" fileName="..\LogMill-FailSafe.log" layout="${TextErrorLayout}" />
      </target>
    </targets>
  </nlog>
</configuration>
Is there a transform option or syntax that I can apply to prevent it from moving the namespace declaration? I couldn't find anything in the documentation
Move your xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" declaration to the topmost element and it should be OK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With