title: Web.Config Transformation Is Overwritten By Pre-Transformed File at End of Build?
body: <p>I am working on a project where we are using web.config transforms to maintain developer-specific configuration data such as pathnames in our local dev environments. It has worked without issue for everyone else, but over the past week the process has stopped working for me. Here is the relevant part of our .csproj triggering the transformation:</p>
  
  <pre><code>&lt;UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" /&gt;
    &lt;Target Name="AfterBuild"&gt;
      &lt;TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="$(IntermediateOutputPath)Web.config" /&gt;
      &lt;ItemGroup&gt;
        &lt;FilesToDelete Include="$(ChoaPhysiciansPortalWebsitePath)\App_Config\Include\PhysiciansPortal\**\*;$(ChoaPhysiciansPortalWebsitePath)\Views\**\*;$(ChoaPhysiciansPortalWebsitePath)\Content\**\*;$(ChoaPhysiciansPortalWebsitePath)\Scripts\**\*;$(ChoaPhysiciansPortalWebsitePath)\Areas\PhysiciansPortal\**\*;" /&gt;
      &lt;/ItemGroup&gt;
      &lt;Delete Files="@(FilesToDelete)" /&gt;
      &lt;CreateItem Include="App_Config\**\*;*.asax;Views\**\*.config;Views\**\*.cshtml;Layouts\*.cshtml;Content\bootstrap\css\*;Content\bootstrap\fonts\*;Content\bootstrap\js\*;Content\css\*.css;Scripts\*;Content\Images\*;Content\fonts\*;Areas\PhysiciansPortal\Views\**\*.cshtml;Areas\PhysiciansPortal\Views\**\*.config;bin\Choa.PhysiciansPortal*.dll;bin\Choa.PhysiciansPortal*.pdb;bin\Castle*.dll;bin\Glass.Mapper*.dll;bin\WebActivator*.dll;bin\Microsoft.Practices.Unity*.dll;bin\System.Web.OData*.dll;bin\Microsoft.OData*.dll;bin\System.Web.Http*.dll;bin\System.Net.Http.Formatting*.dll;bin\Microsoft.Spatial*.dll;bin\Newtonsoft.Json*.dll;deployment\*.aspx;bin\Lucene.Net.dll"&gt;
        &lt;Output ItemName="MvcFiles" TaskParameter="Include" /&gt;
      &lt;/CreateItem&gt;
      &lt;Copy SourceFiles="$(IntermediateOutputPath)Web.config" DestinationFolder="$(ChoaPhysiciansPortalWebsitePath)" /&gt;
      &lt;Copy SourceFiles="@(MvcFiles)" SkipUnchangedFiles="true" DestinationFiles="@(MvcFiles-&gt;'$(ChoaPhysiciansPortalWebsitePath)\%(RelativeDir)%(Filename)%(Extension)')" /&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>So the web.config file is transformed according to my configuration file, Web.Scott.config and is eventually copied to $(ChoaPhysiciansPortalWebsitePath), which represents the IIS website directory for this project. I can see this file get copied over successfully in the build process, with the proper transformations applied, but once the build process is over the destination web.config file is replaced by the original, pre-transform web.config file lacking any of my settings.</p>
  
  <p>I have looked through the verbose MSBuild output and I cannot see anything else in the build process overwriting the transformed web.config file. I am building this project in VS 2012 SP4, and running it with administrator privileges to see if it somehow makes a difference(doesn't appear to).</p>
  
  <p>Has anyone else encountered a similar situation? Right now I am having to copy over a preview of the transformation after every build which is kind of annoying. I look forward to hearing any advice y'all have and hope everyone else is having a great morning :)</p>