Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug the source code of .Net Core or the Base class libraries (coreFx)?

I am using .NET Core 1.0 and Visual Studio 2015 Update 3 to make a simple Asp.Net Core MVC website.

How can I debug my application and "Step Into" the .NET Core source code that is available on GitHub?

Specifically, I am trying to troubleshoot one issue with Microsoft.AspNetCore.Authentication.Facebook 1.0.0 assembly that I fetched from NuGet.

like image 783
Gerardo Grignoli Avatar asked Jul 19 '16 03:07

Gerardo Grignoli


People also ask

How do I Debug .NET Core source code?

To debug . NET and ASP.NET Core source code in Visual Studio: In Tools -> Options -> Debugging -> General, un-check Enable Just My Code. Verify Enable Source Link support is checked.

How do I Debug a .NET program?

Press F5 to run the program in Debug mode. Another way to start debugging is by choosing Debug > Start Debugging from the menu. Enter a string in the console window when the program prompts for a name, and then press Enter . Program execution stops when it reaches the breakpoint and before the Console.


2 Answers

I wrote this article more than 1 year ago so it's a bit out of date but the idea is still the same:

  1. You sync to the correct tag from GitHub. In your case, you probably want to sync to tag 1.0.0
  2. Build that repository by running build.cmd or build.sh
  3. Add the src folder path to your app's global.json file. For example, if you cloned Security in D:\Security, then you add D:/Security/src to global.json in the projects property.
  4. Rebuild everything and it should work.

PS: If you use VS and don't see immediately the new code, try restarting it. It's a known issue that sometimes it doesn't pick up the changes to global.json

like image 173
Victor Hurdugaci Avatar answered Sep 23 '22 15:09

Victor Hurdugaci


Update to fit new VS 2017

In Visual Studio 2017 15.3.5 and later We can use SourceLink support for debugging .NET Core and ASP.NET Core sources. vs 2017 options enable source link To enable source link support just Disable Enable Just My Code and and Enable Enable Source Link Support. Then Enable Microsoft symbol servers. vs 2017 options enable symbol servers


Victors answers works well with vs 2015.For some one who is looking for a solution with vs 2017,
In vs 2017 there is no global.json availble.So instead of adding folder path in global.json a project reference has to be added and rebuild.
All the others mentioned in Victors article works same as with 2015.
It is important that the git hub tag and the nuget package matches have the same versions.

like image 22
nandithakw Avatar answered Sep 21 '22 15:09

nandithakw