can't debug project in omnisharp, even with DebugType=portable or embedded

Viewed 487

I have a .csproj file that I'm unable to debug in VS Code with Omnisharp. Specifically, when I try to debug it, it complains

WARNING: Could not load symbols for '[assembly name].dll'. 'C:\Git\[project]\[assembly name]\bin\Debug\net472\[assembly name].pdb' is a Windows PDB. These are not supported by the cross-platform .NET Core debugger. Loaded 'C:\Git\[project]\TestRunner\bin\Debug\net472\[assembly name].dll'. Cannot find or open the PDB file.

But I've set my DebugType to portable. My .csproj file looks like this:

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <VS_INSTALL_DIR Condition=" '$(VS_INSTALL_DIR)' == '' ">C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional</VS_INSTALL_DIR>
    <LangVersion>8.0</LangVersion>
    <NullableContextOptions>enable</NullableContextOptions>
    <!-- NullableContextOptions was renamed to Nullable, and as of 2019-07-30, dotnet build supports one and Visual Studio supports the other.  
         We should delete NullableContextOptions when we can -->
    <Nullable>enable</Nullable>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <DocumentationFile>bin\$(Configuration)\net472\$(AssemblyName).XML</DocumentationFile>
    <NoWarn>1591;1573</NoWarn>
    <!-- warns when a public member is missing an XML comment, warns when some params have XML comments and others don't -->
    <DebugType>portable</DebugType>
    <EmbedAllSources>true</EmbedAllSources>
    <DebugSymbols>true</DebugSymbols>
    <Platforms>AnyCPU;x86</Platforms>
  </PropertyGroup>

I've also tried <DebugType>embedded</DebugType>, and deleting my obj and bin folders, but I get the exact same message, except it looks for the PDB in the obj folder instead of the bin folder. After building I can see a PDB in the obj folder but not in the bin folder (expected because it should be embedded in the DLL), and it seems Omnisharp tries to load the obj/ PDB instead of the embedded one. And I guess the one in the obj folder is in the "full" PDB format?

(I initially did not have the EmbedAllSources or DebugSymbols settings, but saw a SO post that made me think they might be necessary. I've tried it without those settings with the same result.)

If it's relevant, it's a mixed C#/F# solution, and I can load the symbols for the F# code and the other C# projects in the solution just fine. Every single project in the solution has the DebugType set.

Edit:

Here's my launch.json and tasks.json:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": ".NET Launch (console)",
      "type": "clr",
      "request": "launch",
      "preLaunchTask": "build",
      "program": "${workspaceFolder}/TestRunner/bin/Debug/net472/TestRunner.exe",
      "args": [],
      "cwd": "${workspaceFolder}",
      "console": "internalConsole",
      "stopAtEntry": false,
      "internalConsoleOptions": "openOnSessionStart"
    },
  ]
}
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "command": "dotnet",
      "type": "process",
      "args": [
        "build",
        "TestRunner/TestRunner.fsproj"
      ],
      "problemMatcher": "$msCompile"
    }
  ]
}
0 Answers
Related