Tracing a project was easy in MSBuild 4.0 / VS2010, 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.
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 does no break. The project just runs to completion with VS open.
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 project file.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
InitialTargets="Init">
<UsingTask TaskName="LaunchDebugger"
TaskFactory="Microsoft.Build.Tasks.CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup />
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
System.Console.WriteLine("Launching debugger...");
System.Diagnostics.Debugger.Launch();
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="DebugBreak"
TaskFactory="Microsoft.Build.Tasks.CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup />
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
System.Diagnostics.Debugger.Break();
]]>
</Code>
</Task>
</UsingTask>
<Target Name="Init">
<LaunchDebugger />
<DebugBreak />
</Target>
...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…