即使使用DebugType = portable或Embedded

我有一个.csproj文件,无法使用Omnisharp在VS Code中进行调试。具体来说,当我尝试调试它时,它会抱怨

警告:无法为“ [程序集名称] .dll”加载符号。 “ C:\ Git \ [项目] \ [程序集名称] \ bin \ Debug \ net472 \ [程序集名称] .pdb”是Windows PDB。跨平台的.NET Core调试器不支持这些功能。 已加载“ C:\ Git \ [项目] \ TestRunner \ bin \ Debug \ net472 \ [程序集名称] .dll”。找不到或打开PDB文件。

但是我已经将DebugType设置为Portable。我的.csproj文件如下所示:

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

我也尝试过<DebugType>embedded</DebugType>,并删除了我的obj和bin文件夹,但是得到的消息完全相同,只是它在obj文件夹而不是bin文件夹中查找PDB。构建后,我可以在obj文件夹中看到一个PDB,但在bin文件夹中看不到(预期是因为它应该嵌入DLL中),并且Omnisharp似乎尝试加载obj / PDB而不是嵌入的。而且我猜obj文件夹中的那个是“完整” PDB格式的吗?

((起初我没有EmbedAllSourcesDebugSymbols设置,但是看到了一条SO帖子,使我认为它们可能是必要的。我尝试了没有这些设置的结果相同。 )

如果相关,则它是混合的C#/ F#解决方案,我可以在解决方案中加载F#代码和其他C#项目的符号。解决方案中的每个项目都设置了DebugType。

编辑:

这是我的launch.json和task.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"
    }
  ]
}
mycindy123 回答:即使使用DebugType = portable或Embedded

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2675083.html

大家都在问