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

4

8

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.

Stoa answered 19/7, 2016 at 3:4 Comment(1)
This shows you how to debug ASP.NET Core source code: levelup.gitconnected.com/…Unthinkable
M
11

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.

Mindy answered 18/3, 2017 at 19:13 Comment(1)
How do you put a breakpoint in the source code though? If you try to go to an ASP.NET Core class it just says [from metadata] in the tab and shows you the method signatures only.Unthinkable
N
11

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

Nachison answered 19/7, 2016 at 6:6 Comment(4)
It works! Thank you! Somehow your post didn't showed up when I googled it.Stoa
How would you do this for the core foundation libraries github.com/dotnet/corefx. Such if i just wanted to create a console app to test how the Linq namespace workedParian
@Parian It's the same process. Just clone the corefx repo, sync to the correct tag (that might be a bit hard to find) and the add the src folder to project.jsonNachison
@VictorHurdugaci how to do it in VS2017? Project.json file is no longer exists.Alita
M
11

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.

Mindy answered 18/3, 2017 at 19:13 Comment(1)
How do you put a breakpoint in the source code though? If you try to go to an ASP.NET Core class it just says [from metadata] in the tab and shows you the method signatures only.Unthinkable
H
0

Also make sure that on a solution level, you have your project "configration", set to debug. See screenshot.
. enter image description here.

(For the solution properties to show up, right click on the .sln in the solution explorer.)

Hawsepipe answered 21/10, 2016 at 13:32 Comment(0)
K
0

If you have debugged an app before with the previous version of .NET, delete the %TEMP%/SymbolCache directory as it can have old PDBs that are out of date. Per Debug .NET and ASP.NET Core source code

Kozhikode answered 4/2, 2022 at 23:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.