title: How do I run app.config transformation task first before the PostBuildEvents?
body: <p>I have a console application that uses a database connection string which is defined in app.config. I have a few transformations to change the string depending on the build configuration.</p>
  
  <p>I also have a few post-build events that copy app.config to other projects output. <strong>The problem is post-build event fires first and I copy the untransformed app.config.</strong> Later the transformation task kicks in and apply the transformation (so I know it works). I use with Visual Studio 2010 and .NET 4. </p>
  
  <p>Right now the actions are [1], [<strong>3</strong>], [<strong>2</strong>], I need to reorder them to [1], [2], [3]</p>
  
  <p>1) Build<br>
  2) Run transformation<br>
  3) Run post-build event</p>
  
  <p>Here is my transformation from .csproj</p>
  
  <pre><code>&lt;UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" /&gt;
    &lt;Target Name="Transformation" Condition="exists('app.$(Configuration).config')" &gt;
      &lt;TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" /&gt;
      &lt;ItemGroup&gt;
        &lt;AppConfigWithTargetPath Remove="app.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>And this is my post-build events</p>
  
  <pre><code>&lt;PropertyGroup&gt;
      &lt;RunPostBuildEvent&gt;OnBuildSuccess&lt;/RunPostBuildEvent&gt;
    &lt;/PropertyGroup&gt;
  
   &lt;PropertyGroup&gt;
      &lt;PostBuildEvent&gt;copy $(ProjectDir)app.config $(OutDir)\TH.Presentation.LocalAgent\$(TargetFileName).config
  copy $(ProjectDir)app.config $(OutDir)\TH.Services\$(TargetFileName).config&lt;/PostBuildEvent&gt;
    &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated</p>