title: Config file XDT transformation InsertIfMissing is skipping children
body: <p>I am having trouble doing config transform, adding app settings on nuget package install where element <code>appSetting</code> may or may not exist. </p>
  
  <p><strong>What I want to happen:</strong></p>
  
  <ul>
  <li><code>appSetting</code> element does not exist
  
  <ul>
  <li>Insert <code>appSetting</code> element and its children</li>
  </ul></li>
  <li><code>appSetting</code> element exist
  
  <ul>
  <li>Insert children if missing</li>
  </ul></li>
  </ul>
  
  <p>I only get one or the other to work, but not both occasions.</p>
  
  <p><strong>web.config.install.xdt</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt;
    &lt;appSettings xdt:Transform="InsertIfMissing" &gt;
      &lt;add key="Swagger.Contact.Name" value="Some Name" xdt:Transform="InsertIfMissing" /&gt;
      &lt;add key="Swagger.Contact.Email" value="some@email.address" xdt:Transform="InsertIfMissing" /&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  
  
  <h1>Example 1</h1>
  
  <p><strong>web.config</strong> BEFORE</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5.2" /&gt;
      &lt;httpRuntime targetFramework="4.5.2" maxRequestLength="51200" /&gt;
      &lt;customErrors mode="Off" /&gt;
    &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  
  
  <p><code>appSettings</code> element <strong>not present</strong> before transformation.</p>
  
  <p><strong>web.config</strong> AFTER</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5.2" /&gt;
      &lt;httpRuntime targetFramework="4.5.2" maxRequestLength="51200" /&gt;
      &lt;customErrors mode="Off" /&gt;
    &lt;/system.web&gt;
    &lt;appSettings&gt;
      &lt;add key="Swagger.Contact.Name" value="Some Name" /&gt;
      &lt;add key="Swagger.Contact.Email" value="some@email.address" /&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  
  
  <h1>Example 2</h1>
  
  <p><strong>web.config</strong> BEFORE</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5.2" /&gt;
      &lt;httpRuntime targetFramework="4.5.2" maxRequestLength="51200" /&gt;
      &lt;customErrors mode="Off" /&gt;
    &lt;/system.web&gt;
    &lt;appSettings&gt;
      &lt;add key="Other.Key" value="With Some Value" /&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  
  
  <p><code>appSettings</code> element <strong>present</strong> before transformation.</p>
  
  <p><strong>web.config</strong> AFTER</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5.2" /&gt;
      &lt;httpRuntime targetFramework="4.5.2" maxRequestLength="51200" /&gt;
      &lt;customErrors mode="Off" /&gt;
    &lt;/system.web&gt;
    &lt;appSettings&gt;
      &lt;add key="Other.Key" value="With Some Value" /&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  
  
  <p>Nothing happens in example 2 as the <code>appSettings</code> element already exist, I would like it to still evaluate its child elements and insert those if they do not exist, but it seems they are just ignored. Is there any other value for the attribute <code>xdt:Transform</code> I can use, or any other hacks to work around this issue?</p>