• 利用VS2017跨平台远程调试aspnetcore应用


    vs2017开始支持跨平台远程调试coreclr的应用,通常用于调试linux与mac上运行的aspnetcore程序,而如果运行在docker中的应用
    要使用跨平台远程调试功能,首先运行coreclr应用的环境要可以ssh远程连接,如果应用运行运行在docker中,那么首先需要先安装ssh服务,并启动

    首先要构建一个包含ssh服务的aspnetcore镜像,Dockerfile如下:

    FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
    
    # Install the SSHD server
    RUN apt-get update  
     && apt-get install -y --no-install-recommends openssh-server  
     && mkdir -p /run/sshd
    
    # Set password to '123456'. Change as needed.  
    RUN echo "root:123456" | chpasswd
    
    #Copy settings file. See elsewhere to find them. 
    COPY sshd_config /etc/ssh/sshd_config
    
    # Install Visual Studio Remote Debugger
    RUN apt-get install zip unzip
    RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg  
    EXPOSE 2222
    CMD ["service", "ssh", "start"]
    

    ssh配置文件如下:

    # This is ssh server system wide configuration file.
    #
    # /etc/sshd_config 
    Port                       2222
    ListenAddress              0.0.0.0
    LoginGraceTime             180
    X11Forwarding              yes
    Ciphers aes128-cbc,3des-cbc,aes256-cbc
    MACs hmac-sha1,hmac-sha1-96
    StrictModes                yes
    SyslogFacility             DAEMON
    PasswordAuthentication     yes
    PermitEmptyPasswords       no
    PermitRootLogin            yes
    # Nessesary for VS2017, but not for VSCode!
    Subsystem sftp internal-sftp
    

    该镜像已经构建到 ss22219/dotnet-ssh-debug 可以直接引用

    可以参考 https://github.com/ss22219/Wolf.Blog/blob/master/Dockerfile.dev

    启动ssh后即可在VS 选项->跨平台中设置ssh连接,然后选择调试,附加到进程,连接类型选择SSH,选择连接目标,再选择进程进行调试

    需要注意的是,首次使用coreclr跨平台远程调试会下载调试工具,国内下载速度会比较慢,开启代理可以提高调试启动速度

  • 相关阅读:
    docker使用
    接口自动化python3+requests+pytest/unitest
    Django--日常操作
    Redis
    散碎
    Django-- 类视图 Mixin 扩展类
    Django--类视图
    Django--响应
    python高级--正则表达式
    python-数据类型-字符串--常用操作
  • 原文地址:https://www.cnblogs.com/Gool/p/9781414.html
Copyright © 2020-2023  润新知