vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Breakpoint not hit in cshtml file.

Open kenhan168 opened this issue 9 years ago • 11 comments

Environment data

dotnet --info output: .NET Command Line Tools (2.0.2)

Product Information: Version: 2.0.2 Commit SHA-1 hash: a04b4bf512

Runtime Environment: OS Name: Windows OS Version: 10.0.15063 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.0.2\

Microsoft .NET Core Shared Framework Host

Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.17.2 C# Extension version: 1.12.1

Steps to reproduce

Open the attached proejct EFCoreWebDemo.zip in Visual Studio Code,

Point a breakpoint at file ...Program.cs, line 17: BuildWebHost(args).Run(); Point a breakpoint at file ...\Views\Authors\Index.cshtml, line 9:

  • @author.FirstName @author.LastName
  • .

    Both breakpoints are enabled.

    Start the Debug via Debug -> Start Debugging

    After the debug process fully initialized, only the breakpoint at Program.cs got hit, the one in Index.cshtml got dimmed out with the message "No symbols have been loaded for this document."

    Expected behavior

    Both breakpoints should get hit.

    Actual behavior

    the one in Index.cshtml got dimmed out with the message "No symbols have been loaded for this document."

    kenhan168 avatar Oct 28 '17 02:10 kenhan168

    This is because ASP.NET is compiling your view optimized and/or without PDBs. Though I am not sure why. @BillHiebert do you by chance know what controls this, or have you heard of this problem?

    gregg-miskelly avatar Oct 28 '17 05:10 gregg-miskelly

    @Ryanmailto:[email protected]


    From: Gregg Miskelly [email protected] Sent: Friday, October 27, 2017 10:23:55 PM To: OmniSharp/omnisharp-vscode Cc: Bill Hiebert; Mention Subject: Re: [OmniSharp/omnisharp-vscode] Breakpoint not hit in cshtml file. (#1816)

    This is because ASP.NET is compiling your view optimized and/or without PDBs. Though I am not sure why. @BillHieberthttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbillhiebert&data=02%7C01%7CBill.Hiebert%40microsoft.com%7C0c72544171f04b92207508d51dc41689%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447650390153141&sdata=vw0y0AgbQdd8WADUPRcLOgOmzbvGO%2F4aDrmuqX36AWE%3D&reserved=0 do you by chance know what controls this, or have you heard of this problem?

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOmniSharp%2Fomnisharp-vscode%2Fissues%2F1816%23issuecomment-340140488&data=02%7C01%7CBill.Hiebert%40microsoft.com%7C0c72544171f04b92207508d51dc41689%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447650390153141&sdata=SLYPtxe3tb12RlkhHodoK0uUtxv%2BjgZ4nSgXf22c4MM%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABe1eUxpCC33F45Hk9BHEMTuGSUUWMFpks5swrprgaJpZM4QJyRy&data=02%7C01%7CBill.Hiebert%40microsoft.com%7C0c72544171f04b92207508d51dc41689%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447650390153141&sdata=U%2BRIjAMjoxE80Lb1xjnF0x9RWGDIyOBdbYhZUvlQtqE%3D&reserved=0.

    BillHiebert avatar Oct 29 '17 01:10 BillHiebert

    I'm not certain what I can provide here that will help.

    We always generate a .pdb and we always pass it to Assembly.Load. The emit options we give to roslyn come from the build/project in a round-about way.

    rynowak avatar Oct 30 '17 15:10 rynowak

    @rynowak I debugged it, and the problem is that a non-portable PDB is being generated. Do you know what selects portable vs. Windows?

    gregg-miskelly avatar Oct 30 '17 18:10 gregg-miskelly

    Razor respects the project's settings - and the defaults for the project are set based on the tfm. So if this is netcoreapp20 you get portable by default.

    I believe this snippet does full pdbs

    <DebugType>Full</DebugType>
    

    rynowak avatar Oct 30 '17 18:10 rynowak

    @rynowak the behavior you are describing is what I would expect, but NOT what I am seeing. When I try this in a dotnet new mvc project, the PDB bytes we are sent are in the standard format.

    Here is the project file:

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
      </ItemGroup>
    
      <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
      </ItemGroup>
    
    </Project>
    

    gregg-miskelly avatar Oct 30 '17 20:10 gregg-miskelly

    @pranavkm - can you take a look at this please?

    rynowak avatar Oct 30 '17 20:10 rynowak

    @gregg-miskelly, @rynowak - what is the value of the DebugType property. It should be set to portable. Here's the setting from Microsoft.net.sdk.targets; <DebugType Condition=" '$(DebugType)' == '' ">portable</DebugType>

    BillHiebert avatar Oct 30 '17 21:10 BillHiebert

    Hi all,

    The DebugType was set to "portable" in the project. Appended below.

    netcoreapp2.0 portable

    Ken Han Mobile: +61 (0) 430 817 085 Email: [email protected]

    On 31 October 2017 at 08:02, BillHiebert [email protected] wrote:

    Sorry, forgot about markdoen.

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OmniSharp/omnisharp-vscode/issues/1816#issuecomment-340583382, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkRUO89Yls8rO3V97kWrNkaCJ9UYxr3ks5sxjlZgaJpZM4QJyRy .

    kenhan168 avatar Oct 30 '17 22:10 kenhan168

    Looks like a bug in Mvc. On desktop, we always attempt to produce full pdbs if the pdb writer component is installed (typically installed with VS). It doesn't attempt to read the project's pdb setting. Unfortunately there really isn't a good way for a user to override or specify the pdb kind to produce. I filed https://github.com/aspnet/Mvc/issues/7006 to track fixing this.

    pranavkm avatar Oct 30 '17 23:10 pranavkm

    @pranavkm Thanks! I will resolve this issue as external then.

    gregg-miskelly avatar Oct 30 '17 23:10 gregg-miskelly