title: How to transform log4net config like web.config?
body: <p><strong>From my .csproj file:</strong></p>
  
  <pre><code>&lt;Content Include="log4net.config"&gt;
    &lt;SubType&gt;Designer&lt;/SubType&gt;
  &lt;/Content&gt;
  &lt;Content Include="log4net.Release.config"&gt;
    &lt;DependentUpon&gt;log4net.config&lt;/DependentUpon&gt;
  &lt;/Content&gt;
  &lt;Content Include="log4net.Debug.config"&gt;
    &lt;DependentUpon&gt;log4net.config&lt;/DependentUpon&gt;
  &lt;/Content&gt;
  &lt;Content Include="log4net.Live.config"&gt;
    &lt;DependentUpon&gt;log4net.config&lt;/DependentUpon&gt;   
  &lt;/Content&gt;
  &lt;Content Include="log4net.Demo.config"&gt;
    &lt;DependentUpon&gt;log4net.config&lt;/DependentUpon&gt;   
  &lt;/Content&gt;  
  </code></pre>
  
  <p><strong>At the bottom of my .csproj file:</strong></p>
  
  <pre><code>  &lt;Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /&gt;
    &lt;Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /&gt;
      &lt;Target Name="AfterCompile" Condition="exists('log4net.$(Configuration).config')"&gt;
        &lt;TransformXml Source="log4net.config"
          Destination="$(IntermediateOutputPath)$(TargetFileName).config"
          Transform="log4net.$(Configuration).config" /&gt;
        &lt;ItemGroup&gt;
          &lt;AppConfigWithTargetPath Remove="log4net.config"/&gt;
          &lt;AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config"&gt;
            &lt;TargetPath&gt;$(TargetFileName).config&lt;/TargetPath&gt;
          &lt;/AppConfigWithTargetPath&gt;
        &lt;/ItemGroup&gt;
      &lt;/Target&gt;
  </code></pre>
  
  <p><strong>From log4net.config</strong></p>
  
  <pre><code>&lt;connectionString name="ConnName" 
  value="Data Source=localhost\sqlexpress;Initial Catalog=localdb;Persist Security Info=True;Integrated Security=SSPI;" /&gt;
  </code></pre>
  
  <p><strong>From log4net.Live.config</strong> (removed sensitive data)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt;
      &lt;connectionString name="ConnName" value="Data Source=127.0.0.1;Initial Catalog=DBName;Persist Security Info=True;User ID=userid;Password=pword"
          providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)" /&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I checked msbuild output and I see that it transformed my web.config correctly, but I see no output for it transforming log4net.  Also, when I check the log4net.config file after publish, it has the original connection string.  </p>
  
  <p>What am I doing wrong :)?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Update</strong></p>
  
  <p>I had some errors in the code that msbuild were outputting as warnings that I didn't see.
  I fixed those and now I get some output from MSBuild:</p>
  
  <blockquote>
    <p>AfterCompile:   Transforming Source
    File: log4net.config
        Applying Transform File: log4net.Live.config
        Output File: obj\Live\Common.UI.Web.dll.config<br>
    Transformation succeeded</p>
  </blockquote>
  
  <p>This is still a problem, because the file should be named log4net.config, not Common.UI.Web.dll.config...</p>
  
  <p>For whatever reason </p>
  
  <blockquote>
    <p>$(TargetFileName)</p>
  </blockquote>
  
  <p>is taking on the name of the .csproj file name.  If I replace it with just log4net, then it outputs correctly</p>
  
  <p><strong>Update</strong></p>
  
  <p>File is stuck in obj folder and is not getting picked up when publishing.</p>