dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.35k stars 9.99k forks source link

How to debug aspnetcore source code? #18435

Closed jackletter closed 4 years ago

jackletter commented 4 years ago

I'like debug source code,but how debug this code in Visual Studio

EDIT by @Rick-Anderson for those who get here via search See https://github.com/dotnet/AspNetCore.Docs/issues/4155

Ronkiro commented 4 years ago

Just set breakpoints and then run your application

jackletter commented 4 years ago

I mean debugging the source code of aspnetcore, not my code

xsoheilalizadeh commented 4 years ago

@jackletter, Currently you're able to debug the ASP.NET Core source code, take a look at these links:

Debugging ASP.NET Core 2.0 Source Code Debugging third-party code with Rider

jackletter commented 4 years ago

I try to use symbols to debug the source code, but the prompt is: Https://msdl.microsoft.com/download/symbols: no symbols found on the symbol server. Https://symbols.nuget.org/download/symbols: no symbols found on the symbol server. Here are my project settings: image image

image

Pilchie commented 4 years ago

@dotnet/aspnet-build - how is this currently supposed to be working? Also, @jackletter, it looks like you're running on .NET Core 2.0 which has been out of support for a long time. I recommend upgrading to 3.1, or if that is too big a jump immediately, at least 2.1. Both 2.1 and 3.1 are LTS releases.

See https://dotnet.microsoft.com/platform/support/policy/dotnet-core for details.

dougbu commented 4 years ago

how is this currently supposed to be working?

For 2.0, the instructions at https://www.stevejgordon.co.uk/debugging-asp-net-core-2-source look reasonable. I suspect the out-of-support 2.0 symbols have simply expired and been removed from MSDL.

For anything recent (3.0.0 and on), all of the symbols should be available on MSDL.

There's a symbol checker somewhere in Arcade we might be able to use to confirm the 2.1 symbols are still where we expect (MSDL or perhaps the old NuGet symbol server).

jackletter commented 4 years ago

When I tried version 3.1, the same thing happened: image image image Does the symbol not exist on the server?

dougbu commented 4 years ago

It's possible the issue is geo-distribution of the symbol files but I'm not positive. Could you please provide the exact version information of the files you're checking? I'll check in the next couple of days.

jackletter commented 4 years ago

region 程序集 Microsoft.Extensions.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

// C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.Extensions.Hosting.dll

endregion

I look for assemblies in this order: image

What is a reference assembly? Can't find a symbol related to it?

dougbu commented 4 years ago

What is a reference assembly? Can't find a symbol related to it?

See https://docs.microsoft.com/en-us/dotnet/standard/assembly/reference-assemblies

The information I asked for is only available at runtime. Check the Modules window (Debug -> Windows -> Modules aka Ctrl+D, M) when debugging your application. I can't read the complete Version or Timestamp columns in the screenshots provided earlier.

jackletter commented 4 years ago

image

dougbu commented 4 years ago

I checked everything in the 3.1.1 shared framework and all looks well here in Redmond e.g.

Checking file  C:\Temp\SymbolTest\8cfd4d4d-149a-44d7-9272-1078a500d005\content\shared\Microsoft.AspNetCore.App\3.1.1\Microsoft.Extensions.Hosting.dll ... Symbols found on MSDL (NGen PDB) and SymWeb (NGen PDB)

I'll check 2.1 later today.

dougbu commented 4 years ago

Did a spot check of our 2.1 and 2.2 packages and confirmed their symbols are also available on MSDL. (Minor detail: You don't need the NuGet symbol source for our symbols.)

I also debugged a default ASP.NET Core MVC application and successfully downloaded all of the symbols: image

The issue you're having @jackletter is likely a networking problem, either geo-location (as I mentioned earlier) or an intervening proxy refusing to connect to the symbol servers and (oddly) returning a 404.

Pilchie commented 4 years ago

Closing as we can't seem to reproduce this issue locally.

fangqifan commented 4 years ago

@jackletter you need SS or V2ray to bypass GFW