调试 Nuget 库 [英] Debug Nuget Library

查看:59
本文介绍了调试 Nuget 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一套自己编译和修改的 Nuget 库.

我在没有在任何 Nuget 服务器上发布的情况下构建它们.(这不是我的图书馆)

另一方面,我有一个使用此类 Nuget 的项目,但我想调试它们...

在最好的情况下,我希望:

  • 使用我本地的 .dll 和 .pdb
  • 使用本地 .pdb 和(更新的)源代码进行调试

我正在寻找最好的解决方案,如果可能的话,通过加载所有本地符号,但我不确定这是可能的.

也许我必须在我自己的本地 Nuget 服务器上构建并使用本地 Symbol 服务器,但它看起来有点矫枉过正?

解决方案

也许我必须在我自己的本地 Nuget 服务器上构建并使用本地符号服务器也是,但它看起来有点过分?

据我所知,当你想在一个新项目中调试一个nuget库时,你必须添加所需的nuget.pdb和相关的xxx.cs源码新项目中的文件.

根据你的描述,nuget包是自己创建的,比较容易实现:

1)如果本地有nuget.pdb文件和对应的cs文件,只需要把PDB 文件在引用 nuget 的项目的输出文件中,然后右键单击 Solution-->Properties-->Common Properties-->Debug Source Files-->添加cs文件所在的文件夹路径.

2) 如果你没有当前的nuget.pdb文件和相关的cs源文件用于本地调试,你需要在nuget.nupkg 使用

然后打开它并添加如下:

<file src="bin\Debug\ClassLibrary11.pdb" target="lib\target framework version (like net472 or netstandard2.0)"/>------ClassLibrary11.pdb是nuget.pdb<file src="Class1.cs" target="src"/>------Class1.cs是源文件</文件></包>

D) 然后输入 nuget pack 以生成包含这些调试文件的 nuget 包.

E) 在新项目中安装此 nuget 包时,请不要忘记 首先清理 nuget 缓存.之后,您应该将资源文件的路径添加到Debug Source Files中.(资源文件存在于C:\Users\xxx\.nuget\packages\package name\srcC:\xxxxx\ConsoleApp(项目文件夹)\packages\package name\src)

编辑

F) 开始调试时,请不要忘记在 Tools-->Options 中禁用 Just My Code-->Debugging-->General-->取消勾选Enable Just My Code.

此外,您可以将源链接视为源代码控制,因此您不会通过 Solution=>properties 配置源路径.

另外,可以参考这个类似的问题.

I have a set of Nuget Libraries that I compile and modify myself.

I build them without publishing on any Nuget server. (It is not my library)

On the other side, I have a project that use such Nugets, but I wish to debug them...

In the best situation I wish to:

  • use my local .dll and .pdb
  • debug by using local .pdb and (updated) source code

I'm looking for the best possible solution, if possible by loading all local symbols, but I'm not sure it is possible.

Maybe I have to build on my own local Nuget server and use a local Symbol server too, but it looks overkill?

解决方案

Maybe I have to build on my own local Nuget server and use a local Symbol server too, but it looks overkill?

As far as l know, when you want to debug a nuget library in a new project, you must add the required nuget.pdb and related xxx.cs source files in the new project.

According to your description, the nuget package is created by yourself which is more easiler to realize it:

1) If you have the nuget.pdb file and the corresponding cs file on the local, you just need to put the PDB file in the output file of the project which references the nuget, and then right-click on the Solution-->Properties-->Common Properties-->Debug Source Files-->to add the folder path which the cs files exist into it.

2) If you do not have the current nuget.pdb file and related cs source files for debugging on the local, you need to include these files in nuget.nupkg when creating the nuget package by using nuget.exe cli with xxx.nuspec, so that these files can be added to the current agent when you install the nuget package.

**Note:**This is the special steps for creating your nuget package:

A) please make sure that you have downloaded the nuget.exe and then set its path to environment variables so that it can be called in CMD. You can refer to this.

B) Open CMD, type cd xxxxxx(the path of the project which contains xxxx.csproj)

C) type nuget spec to generate the xxx.spec file

Then open it and add like these:

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
   ........
  </metadata>
<files>
<file src="bin\Debug\ClassLibrary11.pdb" target="lib\target framework version (like net472 or netstandard2.0)" />------ClassLibrary11.pdb is the nuget.pdb
 <file src="Class1.cs" target="src" />------Class1.cs is the source file
</files>
</package>

D) then type nuget pack to generate the nuget package which contains these debug files.

E) when you install this nuget package in a new project, please do not forget to clean the nuget cache first. After that, you should add the path of the resource files into Debug Source Files.(the resource files exists in the C:\Users\xxx\.nuget\packages\package name\src or C:\xxxxx\ConsoleApp(project folder)\packages\package name\src)

Edit

F) When you start debugging it, please do not forget to disable Just My Code In Tools-->Options-->Debugging-->General-->uncheck Enable Just My Code.

Also, you can consider source links as source control so that you won't configure the source path by Solution=>properties.

In addition, you can refer to this similar issue.

这篇关于调试 Nuget 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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