Visual Studio 2017在从Docker Windows容器远程调试.Net Core控制台应用程序时无法加载调试符号

4

当远程调试一个托管在 Windows Docker 容器上的 .NET Core 控制台应用程序时,无法通过代码进行步进。即使 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 运行,客户端 Web.Identity.Client.Mvc.pdb 存在于 dll 路径中。

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
1个回答

1

通常情况下,Visual Studio会在IDE侧加载PDB文件而不是容器中。因此,解决这个问题的最简单方法是在Windows侧构建项目,然后PDB文件会自动加载。或者,您可以将PDB构建到映射到主机驱动器的文件夹中,并将该文件夹添加到“工具”->“选项”->“调试器”->“符号”中的符号搜索列表中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接