【问题标题】:Visual Studio 2017 Does Not Load Debug Symbols When Remote Debugging a .Net Core Console App from a Docker Windows Container从 Docker Windows 容器远程调试 .Net Core 控制台应用程序时,Visual Studio 2017 不加载调试符号
【发布时间】:2017-12-26 16:30:03
【问题描述】:

远程调试托管在 Windows docker 容器上的 .net 核心控制台应用程序时,无法单步执行代码。即使 PDB 与 DLL 一起存在,也会出现错误“无法找到或打开 PDB 文件”。

Dockerfile

FROM microsoft/windowsservercore

WORKDIR /

COPY ./tools ./

RUN dotnet-dev-win-x64.1.0.4.exe /install /quiet
RUN vs_remotetools.exe /install /quiet

EXPOSE 4022

COPY ./Clients/Client.Web.Identity.Client.MVC ./Clients/Client.Web.Identity.Client.MVC

WORKDIR ./Clients/Client.Web.Identity.Client.MVC
RUN dotnet restore Client.MVC.csproj
RUN dotnet build Client.MVC.csproj
CMD dotnet run http://*60720

Visual Studio 调试输出 https://pastebin.com/D77JCtr9

注意第二行:

'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Clients\Client.Web.Identity.Client.MVC\bin\Debug\netcoreapp1.1\Client.Web.Identity.Client.Mvc.dll'. Cannot find or open the PDB file.

容器输出显示 MSVSMON 与 dll 路径中存在的 Client.Web.Identity.Client.Mvc.pdb 一起运行。

PS C:\clients\Client.Web.Identity.Client.MVC\bin\debug\netcoreapp1.1> hostname
1aaaef767980
PS C:\clients\Client.Web.Identity.Client.MVC\bin\debug\netcoreapp1.1> dir


    Directory: C:\clients\Client.Web.Identity.Client.MVC\bin\debug\netcoreapp1.1


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        7/20/2017  11:45 AM         561664 IdentityServer4.dll
-a----        7/20/2017  11:45 AM         160224 IdentityServer4.pdb
-a----        7/20/2017  11:45 AM         385545 IdentityServer4.xml
-a----        7/20/2017  11:45 AM         239282 Client.Web.Identity.Client.Mvc.deps.json
-a----        7/20/2017  11:45 AM          31744 Client.Web.Identity.Client.Mvc.dll
-a----        7/20/2017  11:45 AM           5544 Client.Web.Identity.Client.Mvc.pdb
-a----        7/20/2017  11:47 AM            133 Client.Web.Identity.Client.Mvc.runtimeconfig.dev.json
-a----        7/20/2017  11:47 AM            192 Client.Web.Identity.Client.Mvc.runtimeconfig.json
-a----        7/20/2017  11:45 AM          13312 Client.Web.Identity.Common.dll
-a----        7/20/2017  11:45 AM           3812 Client.Web.Identity.Common.pdb

PS C:\clients\Client.Web.Identity.Client.MVC\bin\debug\netcoreapp1.1> get-process

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
     90       5      968       4612       0.77   1600   1 CExecSvc
     42       3     1556       2752       0.05   1880   1 cmd
    209      11     1868       4412       1.36     68   1 csrss
    476     340    50400      40372       1.84    876   1 dotnet
    475      44    27516      47552       1.67   2044   1 dotnet
      0       0        0          4                 0   0 Idle
    735      20     4388      12764       1.91    644   1 lsass
    188      12     2276       9200       0.31    376   1 msdtc
    174      12     1948       8748       0.56   1100   1 msvsmon
    690      33    16612      39668       7.36   2160   1 msvsmon
    113       9     1360       6964       0.06   2484   1 msvsmon
    128      10     1320       6724       0.05   2604   1 msvsmon
   1227      50   102760     119608      14.39   1420   1 powershell
    178       8     1840       5796       1.36    536   1 services
     48       2      344       1156       8.45    988   0 smss
    352      14    17816      25500       7.19   2316   1 StandardCollector.Service
    283      12     2384       9084       0.75   1052   1 svchost
    253      13     2000       6876       0.84   1088   1 svchost
    271      13     2508      10460       0.72   1196   1 svchost
    288      14     5164      10636       2.50   1212   1 svchost
    849      32    10992      29032       8.89   1256   1 svchost
    188      16     3124      10104       0.88   1268   1 svchost
    390      31     5540      15760       1.97   1388   1 svchost
     89       6     1044       5344       0.13   1500   1 svchost
    354      18     4676      14180       1.83   1512   1 svchost
   3352       0      128        136      46.97      4   0 System
     91       8      908       5156       0.45    316   1 wininit

【问题讨论】:

    标签: docker .net-core visual-studio-2017 remote-debugging


    【解决方案1】:

    Visual Studio 通常会在 IDE 端而不是在容器中加载 PDB 文件。所以解决这个问题的最简单方法是在 Windows 端构建您的项目,然后 PDB 将自动加载。或者,您可以将 PDB 构建到映射到主机驱动器的文件夹中,然后将该文件夹添加到 Tools->Options->Debugger->Symbols 中的符号搜索列表中。

    【讨论】:

      猜你喜欢
      • 2019-11-29
      • 2017-08-15
      • 1970-01-01
      • 2017-12-20
      • 2018-05-28
      • 2018-06-19
      • 2018-07-27
      • 2018-07-01
      相关资源
      最近更新 更多