title: Make Web.config transformations work locally
body: <p>I want to get web.config transformations working locally but apparently the transformations only occur when doing deployments. </p>
  
  <p>Does anybody know of a way to run the msbuild target "TransformWebConfig" without it going through the "rebuild" process and also specify and output directory where to spit out the transformed web.config?</p>
  
  <p><strong>EDIT</strong>: Using Sayed's answer, I created a <code>.bat</code> file to do run the task for me:</p>
  
  <pre><code>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Msbuild.exe "D:\Demo\Transformation.proj" /t:TransformWebConfig 
  
  copy /Y  "D:\Demo\Web.config" "D:\MyProject\Web.config" 
  
  del ""D:\Demo\Web.config"
  </code></pre>
  
  <p>the "Transformation.proj" is a copy of Sayed's code snippet in the answer below.  Just specify the source, target, and destination for the transformation.  The new file, in this case, the transformed "web.config" will be in the "D:\Demo" directory. I am simply copying it over to overwrite my project's web.config and, finally, deleting the generated file in the "demo" folder.</p>
  
  <p>Also, I created a macro to run this batch file and perform the tranformation for me:</p>
  
  <pre><code>Public Module DoTransform
      Sub RunTransformBatchFile()
          Try
            Process.Start("D:\Demo\RunTransform.bat")
          Catch ex As System.Exception
              MsgBox(ex.Message)
          End Try
      End Sub
  End Module
  </code></pre>
  
  <p>You can also add a button on your toolbar to run this batch and/or assign a shortcut key to execute.</p>