如何在我创建的nuget包中调试代码 [英] How to debug code in a nuget package created by me

查看:327
本文介绍了如何在我创建的nuget包中调试代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个nuget程序包,它是在另一个解决方案中创建并安装的,但是现在我需要在从新解决方案中调用该程序包时调试该程序包的代码.

I have a nuget package I created and installed in another solution but now I need to debug de code of the package when called from my new solution.

我尝试引用该软件包的解决方案,但无法正常工作.

I tried referencing the solution of the package but is not working.

我正在使用Visual Studio 2013.

I am using Visual Studio 2013.

推荐答案

要调试任何dll,您需要其符号文件(.pdb).如果您以debug配置来构建项目,您将看到这些文件已生成并放置在构建输出文件夹中.

To debug any dll you need the symbol file of it (.pdb). If you build your project in the debug configuration you will see that those files are generated and put in the build output folder.

Visual Studio如此处所述,从不同位置加载这些符号文件.调试nuget软件包的最简单方法是将软件包的.pdb文件放入要调试的项目的build输出文件夹中.

Visual studio loads those symbol files from different places as described here. The easiest way to debug your nuget packages is to put the .pdb files of the packages in the build output folder of the project you want to debug.

如果您要调试的代码被归类为非用户代码,则需要在调试选项中 取消选中 Just My Code.

If the code you are trying to debug is classified as non-user code you need to uncheck Just My Code in the debugging options.

用户和非用户代码

为了区分用户代码与非用户代码,仅我的代码"着眼于符号(.pdb)文件和程序优化.当二进制文件经过优化或.pdb文件不可用时,调试器会将代码视为非用户代码.

To distinguish user code from non-user code, Just My Code looks at symbol (.pdb) files and program optimizations. The debugger considers code to be non-user code when the binary is optimized or when the .pdb file is not available.

三个属性也会影响调试器认为是我的代码的地方:

Three attributes also affect what the debugger considers to be My Code:

  • DebuggerNonUserCodeAttribute告诉调试器它所应用的代码不是我的代码.
  • DebuggerHiddenAttribute从调试器中隐藏代码,即使仅我的代码"已关闭.
  • DebuggerStepThroughAttribute告诉调试器单步执行它所应用的代码,而不是单步执行代码.

所有其他代码均视为用户代码.

All other code is considered to be user code.

这篇关于如何在我创建的nuget包中调试代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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