Rafael
Rafael

Reputation: 2009

Embedding debugging information to the build does not include any debugging symbols

In my project, in the Build - Advanced section I've set "Debugging information: Embedded":

setting embedded debug info

Also, I have set an option to package my project as nupkg file.

setting create package

As the project has built there is a nupkg file created, but when I use this nupkg file upon debugging another project there are no symbols included, nor PDB file is included inside of nupkg file.

My questions: as far as I understand I have to do different steps to include PDB file into my nupkg. In this case, what is the purpose of "Debugging information: Embedded" option, why it is available and what does it do? Because no debugging information is included in the result package file even this option is enabled.

Thank you.

Upvotes: 2

Views: 1846

Answers (1)

Mr Qian
Mr Qian

Reputation: 23715

Embedding debugging information to the build does not include any debugging symbols

Debugging information: Embedded means that MSBuild will embed the PDB file directly into the target DLL, meaning that the DLL not only contains its own DLL but also contains the contents of the PDB file. A DLL already contains two contents: itself and the pdb file.

As the project has built there is a nupkg file created, but when I use this nupkg file upon debugging another project there are no symbols included, nor PDB file is included inside of nupkg file.

So you do not have to worry about missing the pdb file, it is already be put into the DLL.

And if you want to debug the nuget package's content locally in another project, you should only pack the source files(cs files) into nuget package.

1) Add such pack nodes in your lib project.

<ItemGroup>
        <Compile Update="Class1.cs" Pack="true" PackagePath="SourceFiles"></Compile>

        //add any source files like this if you want to debug their functions
</ItemGroup>

It will pack the source files into a folder called SourceFiles of the nupkg.

enter image description here

enter image description here

The purpose is to package the source file along with nuget so that the source file can be directly taken out of the package for subsequent debugging to ensure successful debugging.

2) then pack the project, before you install this new version of the package into the project, you should first uninstall the old one, clean nuget caches or just delete all files under C:\Users\xxx(current user)\.nuget\packages, then install the new one.

3) Before you debug the project, you should first add the source files of the nuget in to the solution.Otherwise, VS will report an error that the nuget source file cannot be found when debugging.

Right-click on the solution-->Properties-->Common Properties-->Debug Source Files

input the SourceFiles folder of the nuget into it:

enter image description here

In addition, there is a similar issue about it.

This is a sample about my test:

enter image description here

Upvotes: 2

Related Questions