Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

visual studio - Debug Nuget Library

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

enter image description here

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

enter image description here

Then open it and add like these:

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
   ........
  </metadata>
<files>
<file src="binDebugClassLibrary11.pdb" target="libarget 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:Usersxxx.nugetpackagespackage namesrc or C:xxxxxConsoleApp(project folder)packagespackage namesrc)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...