title: How to debug a project file in MSBuild 12.0 / VS2013?
body: <p><a href="http://blogs.msdn.com/b/msbuild/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx">Tracing a project was easy in MSBuild 4.0 / VS2010</a>, all you had to do was set registry key which enabled an msbuild /debug command line option.  The debugger would launch and break at the start of the project file.</p>
  
  <p>MSBuild 12 introduces a new environment variable for this. At the command prompt, set MSBUILDDEBUGONSTART=1 and then run MSBuild (no command line switch).  This launches the debugger, but <strong>does no break</strong>.  The project just runs to completion with VS open.</p>
  
  <p>Am I missing a setting?  Or has this (undocumented) feature been removed?  I was able to at least get the debugger to halt by hard coding in a debug break, but this does not help me trace the <em>project</em> file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
           InitialTargets="Init"&gt;
  
    &lt;UsingTask TaskName="LaunchDebugger"
               TaskFactory="Microsoft.Build.Tasks.CodeTaskFactory"
               AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"&gt;
      &lt;ParameterGroup /&gt;
      &lt;Task&gt;
        &lt;Using Namespace="System" /&gt;
        &lt;Code Type="Fragment" Language="cs"&gt;
          &lt;![CDATA[
            System.Console.WriteLine("Launching debugger...");
            System.Diagnostics.Debugger.Launch();
          ]]&gt;
        &lt;/Code&gt;
      &lt;/Task&gt;
    &lt;/UsingTask&gt;
  
    &lt;UsingTask TaskName="DebugBreak"
               TaskFactory="Microsoft.Build.Tasks.CodeTaskFactory"
               AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"&gt;
      &lt;ParameterGroup /&gt;
      &lt;Task&gt;
        &lt;Using Namespace="System" /&gt;
        &lt;Code Type="Fragment" Language="cs"&gt;
          &lt;![CDATA[
            System.Diagnostics.Debugger.Break();
          ]]&gt;
        &lt;/Code&gt;
      &lt;/Task&gt;
    &lt;/UsingTask&gt;
  
    &lt;Target Name="Init"&gt;
      &lt;LaunchDebugger /&gt;
      &lt;DebugBreak /&gt;
    &lt;/Target&gt;
  
  ...
  </code></pre>