dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 673 forks source link

Latest Code/OmniSharp (1.6.0-beta3) doesn't load symbols for my project when attaching #1019

Closed aggieben closed 7 years ago

aggieben commented 7 years ago

Environment data

dotnet --info output:

λ dotnet --info
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

VS Code version: 1.7.2 C# Extension version: 1.6.0-beta3

Steps to reproduce

Created new web project with preview2 CLI like this: dotnet new -t web

// actively developed project

try to attach to running process

Expected behavior

Symbols loaded and debugger fully functional.

Actual behavior

No symbols loaded for my project, breakpoints not hit.

gregg-miskelly commented 7 years ago

@aggieben Do you have portable PDBs enabled? https://github.com/omniSharp/omnisharp-vscode/wiki/Portable-PDBs

If so -

aggieben commented 7 years ago

Yep, I have debugType set to portable. I pasted the entire project.json at the bottom.

There are warnings printed to the debugger console indicating a failure to load symbols for system assemblies, but nothing else. There is no mention of my module that I can see, either.


{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "copyToOutput": [
        "hosting.json",
        "config.json",
        "idsrv_signing_cert.pfx",
        "localhost.pfx",
        "Features",
        "wwwroot"
    ]
  },
  "scripts": {
      "precompile": [
          "dotnet script %project:Directory%/Scripts/GenerateAssemblyInfo.csx %project:Directory%/AssemblyInfo.cs.tmpl"
      ]
  },
  "publishOptions": {
      "include": [
          "Features",
          "wwwroot",
          "hosting.json",
          "config.json",
          "config.dev.json",
          "idsrv_signing_cert.pfx",
          "localhost.pfx"
      ]
  },
  "dependencies": {
      "AWSSDK.Core": "3.3.3",
      "AWSSDK.CloudWatch": "3.3.0.1",
      "AWSSDK.EC2": "3.3.2",
      "IdentityModel": "2.0.0",
      "IdentityServer4": "1.0.0-rc3",
      "IdentityServer4.AspNetIdentity": "1.0.0-rc3",
      "IdentityServer4.EntityFramework": "1.0.0-rc3",
      "Microsoft.AspNetCore.Diagnostics": "1.0.0",
      "Microsoft.AspNetCore.HttpOverrides": "1.0.0",
      "Microsoft.AspNetCore.Hosting": "1.0.0",
      "Microsoft.AspNetCore.Mvc": "1.0.1",
      "Microsoft.AspNetCore.Mvc.DataAnnotations": "1.0.1",
      "Microsoft.AspNetCore.StaticFiles": "1.0.0",
      "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
      "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.1",
      "Microsoft.Extensions.Caching.Memory": "1.0.0",
      "Microsoft.Extensions.Configuration.Json": "1.0.0",
      "Saddleback.Cm.Sdk": {
          "target": "project"
      },
      "Saddleback.Extensions": {
          "target": "project"
      },
      "Saddleback.IdentityServer.Data": {
          "target": "project"
      },
      "Serilog": "2.2.1",
      "Serilog.Extensions.Logging": "1.2.0",
      "Serilog.Settings.Configuration": "2.2.0",
      "Serilog.Sinks.AwsCloudWatch": "2.0.49",
      "Serilog.Sinks.Literate": "2.0.0"
  },
  "tools": {
      "Microsoft.DotNet.Watcher.Tools": "1.0.0-*",
      "BitThicket.DotNet.ScriptTool": {
          "version": "0.1.0-*",
          "imports": [ "dotnet" ]
      }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.*"
        }
      },
      "imports": [
          "dnxcore50"
      ]
    }
  },
  "runtimes": {
      "win10-x64": {},
      "debian.8-x64": {},
      "ubuntu.14.04-x64": {},
      "ubuntu.16.04-x64": {}
  }
}```
gregg-miskelly commented 7 years ago

@aggieben if the debugger doesn't see your module even loaded, then that is certainly the problem. Are you sure you are debugging the right process (maybe write your process id to the console)?

aggieben commented 7 years ago

@gregg-miskelly I was fairly sure I had the right pid - pulled it from procexp to be sure - but not you've got me doubting, so I'll double check and post back.

aggieben commented 7 years ago

Yes, I picked the right PID to attach. Here's the entirety of the debugger output when I attach:

Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\System.Runtime.Serialization.Primitives.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Xml.ReaderWriter.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Security.Cryptography.Algorithms.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Globalization.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Security.Cryptography.Primitives.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\Microsoft.DotNet.Files.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Protocol.Core.Types.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Commands.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.DependencyResolver.Core.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Repositories.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Configuration.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Protocol.Core.v3.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.ProjectModel.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.DependencyResolver.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.LibraryModel.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Packaging.Core.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.RuntimeModel.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.Client.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\NuGet.ContentModel.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Threading.Overlapped.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Text.Encoding.Extensions.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Threading.ThreadPool.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Resources.ResourceManager.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.AppContext.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Reflection.Emit.ILGeneration.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Reflection.Primitives.dll'. Cannot find or open the symbol file.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Reflection.Emit.Lightweight.dll'. Cannot find or open the symbol file.
Loaded 'Anonymously Hosted DynamicMethods Assembly'. Cannot find or open the symbol file.

There is no mention of my assembly, Saddleback.IdentityServer.Web.dll.

gregg-miskelly commented 7 years ago

@aggieben from process explorer do you see your dll loaded in this process?

aggieben commented 7 years ago

Aha! So just assumed like a goofball that I should attach to dotnet.exe because the debugger sorts those processes to the top, but I'm actually building my application as a self-contained app, which means the process I care about is actually Saddleback.IdentityServer.Web.exe, which is another processed owned by the dotnet.exe CLI because I execute it with dotnet run.

Makes sense now. I attached to Saddleback.IdentityServer.exe and it loaded my module's symbols just fine.

gregg-miskelly commented 7 years ago

Cool. Glad you solved it.