Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakpoint not hit in cshtml file. #1816

Closed
kenhan168 opened this issue Oct 28, 2017 · 11 comments
Closed

Breakpoint not hit in cshtml file. #1816

kenhan168 opened this issue Oct 28, 2017 · 11 comments

Comments

@kenhan168
Copy link

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."

    @gregg-miskelly
    Copy link
    Contributor

    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?

    @BillHiebert
    Copy link

    BillHiebert commented Oct 29, 2017 via email

    @rynowak
    Copy link
    Member

    rynowak commented Oct 30, 2017

    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.

    @gregg-miskelly
    Copy link
    Contributor

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

    @rynowak
    Copy link
    Member

    rynowak commented Oct 30, 2017

    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>
    

    @gregg-miskelly
    Copy link
    Contributor

    @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>

    @rynowak
    Copy link
    Member

    rynowak commented Oct 30, 2017

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

    @BillHiebert
    Copy link

    BillHiebert commented Oct 30, 2017

    @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>

    @kenhan168
    Copy link
    Author

    kenhan168 commented Oct 30, 2017 via email

    @pranavkm
    Copy link

    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 aspnet/Mvc#7006 to track fixing this.

    @gregg-miskelly
    Copy link
    Contributor

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

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants