How to debug ASP.NET Core 2.0 source code
If you are a .net developer and love the fact you could debug your code easily by attaching the process to your code and go through it using keyboard shortcuts like F10 and F11. Well, the good news is that it becomes even easier to load assemblies that you don’t have it in your local such as:
Microsoft team has already uploaded the PDBs of ASP.NET Core 2.0 on the Microsoft Symbol Servers. And if you are using Visual Studio 2017 15.3, Source Link Support for Windows PDB File Format, that is what you need to start with. Quote from Microsoft website:
Source Link supports Windows PDB file format (we had Portable PDBs supported from before). Debugger can retrieve the source files based on Windows PDB file format.
Just create a new ASP.NET Core 2.0 Web application, remember you have to use Visual Studio 2017 15.3 or newer version.
Put a breakpoint on Startup class, and set a breakpoint on the ConfigureServices method, start the application and you will hit that breakpoint
Open the external code and select one of the external DLLs, let’s say Microsoft.AspNetCore.Hosting.dll.
Right click on Microsoft.AspNetCore.Hosting.dll and choose Load Symbols, Then the following dialog will be shown, start downloading the symbols from Microsoft Symbol Servers.
The following dialogue might pop up and ask whether you want to download it, select the appropriate option.
And voila, magic! you can now debug codes that are not even part of your solution.