如何在MSBuild 12.0 / VS2013中调试项目文件? [英] How to debug a project file in MSBuild 12.0 / VS2013?

查看:149
本文介绍了如何在MSBuild 12.0 / VS2013中调试项目文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跟踪项目很简单在MSBuild 4.0 / VS2010中,您只需设置注册表项即可启用msbuild / debug命令行选项。调试器将在项目文件开始时启动并中断。

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为此引入了一个新的环境变量。在命令提示符下,设置MSBUILDDEBUGONSTART = 1,然后运行MSBuild(无命令行开关)。这将启动调试器,但不会中断。该项目刚刚完成,VS开放。

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>

...


推荐答案

DebuggerEnabled 注册表值(数据 true )添加到以下键(博客帖子中的键)已经过时了)

Add the DebuggerEnabled registry value (with data true) to the following key(s) (the key in the blog post is out of date).

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\12.0 (64位系统)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\12.0 (32位系统,或
如果以某种方式运行MSBuild 64位)

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\12.0 (64-bit systems) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\12.0 (32-bit systems, or if somehow running MSBuild 64-bit)

另见:

  • http://stackoverflow.com/a/27450702/704808
  • https://connect.microsoft.com/VisualStudio/feedback/details/1029251/cannot-debug-msbuild-project-script-file#commentContainer

这篇关于如何在MSBuild 12.0 / VS2013中调试项目文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆