Search code examples
.netvisual-studiodebuggingxamarin.formspdb-files

How can I debug the library using .pdb file?


I have been looking through ways to **debug external projects like BaseLibrary **. So I haven't seen such a code structure or worked on it. I think I can debug those projects with the use of the .pdb file present in the output.

enter image description here

This is how the project structure looks like. And I will be debugging the last project which is being highlighted. I have gone through these links

https://learn.microsoft.com/en-us/visualstudio/debugger/specify-symbol-dot-pdb-and-source-files-in-the-visual-studio-debugger?view=vs-2019

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/internals/sourcelink?pivots=windows

I have added references for pdb file. I'm not sure if it is incorrect format the reference of pdb file is C:\Workspace\Xamarin.IntegrationLibrary\Output\netstandard2.1 as you can see in the following image.

enter image description here

But they are not helping me with my requirement because it is talking about debugging the NuGet packages which I'm installing in my current project. I want to debug the external projects. Currently, I'm able to navigate to assembly of the base library but I'm not able to navigate to source code or methods. As you can see in the following image.

enter image description here

I even tried debugging in dnSpy but I'm not able to give the executable for that. Also, it is not exactly what I require because I have to debug within the project using pdb.

enter image description here Some solution says double-clicking on the DLL in the module opens the source code. Well I tried that as well as you can see the following screenshot

enter image description here I am able to load the .pdb symbols but I want to navigate and debug the source code of base library and integration library from xamarin.xyzApp project. I have no clue how to proceed with this. Any suggestions?


Solution

  • I fixed that by adding the following code in Directory.Build.props of BaseLibrary(Any library which we want to debug) and restart your visual studio

    <PropertyGroup>
        <IncludeSymbols>true</IncludeSymbols>
        <SymbolPackageFormat>snupkg</SymbolPackageFormat>
    </PropertyGroup>
    

    Check the properties of the project file by navigating through properties of each project you want to debug-> Build ->Advanced and check if the debug information is embedded. Rebuild BaseLibrary solution and check .snupkg files are generated in base library's Output folder.