{"id":52421,"date":"2017-01-26T11:48:01","date_gmt":"2017-01-26T18:48:01","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/devops\/?p=52421"},"modified":"2019-02-14T15:55:53","modified_gmt":"2019-02-14T23:55:53","slug":"debugging-net-core-on-unix-over-ssh","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/debugging-net-core-on-unix-over-ssh\/","title":{"rendered":"Debugging .NET Core on Unix over SSH"},"content":{"rendered":"<p>With the release of Visual Studio 2017 RC3 it is now possible to attach to .NET Core processes running on Linux over SSH. This blog post will explain how to set this up.<\/p>\n<h3>Machine Setup<\/h3>\n<p>On the Visual Studio computer, you need to install either the &#8216;ASP.NET and web development&#8217; or the &#8220;.NET Core cross-platform development&#8221; workload in the <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2017\/01\/26\/update-to-visual-studio-2017-release-candidate\/\">1\/26\/17 update<\/a> for\u00a0<a href=\"https:\/\/www.visualstudio.com\/vs\/visual-studio-2017-rc\/\">VS 2017 RC<\/a>. If you previously installed Visual Studio 2017 RC, you can see if it is an RC3 release from Help-&gt;About.<\/p>\n<p>On the Linux server, you need to install SSH server, unzip and either curl or wget. For example, on Ubuntu you can do that by running:<\/p>\n<p><code>sudo apt-get install openssh-server unzip curl<\/code><\/p>\n<h3>Deploying the Application<\/h3>\n<p>In order to debug your application running on Linux, it will first need to be deployed there. One option for doing this is to copy sources to the target computer and build with \u2018dotnet build\u2019 on the Linux machine. Another option would be to build on Windows, and transfer the built artifacts (the application itself, any runtime libraries it might depend on and the .deps.json file).<\/p>\n<p>For debugging, there are two important notes. First, it is much harder to debug retail-compiled code than debug-compiled code, so it is highly recommended to use the \u2018Debug\u2019 configuration. If you do need to use the \u2018Release\u2019 configuration, make sure to disable Tool-&gt;Options-&gt;Debugging-&gt;Just My Code. Second, the debugger for Linux will need to make sure <a href=\"https:\/\/github.com\/OmniSharp\/omnisharp-vscode\/wiki\/Portable-PDBs\">Portable PDBs<\/a> are enabled (which is the default), and they will need to be next to the dll.<\/p>\n<h3>Attaching the Debugger<\/h3>\n<p>Once the computers are configured and the application is up and running now we are ready to attach the debugger.<\/p>\n<ol>\n<li>Go to Debug-&gt;Attach to Process\u2026<\/li>\n<li>In the \u2018Connection Type\u2019 drop down, select \u2018SSH\u2019<\/li>\n<li>Change the \u2018Connection Target\u2019 to the IP address or host name of the target computer<\/li>\n<li>Find the process that you would like to debug. By default, your code will run in a \u2018dotnet\u2019 process. You can look at the \u2018Title\u2019 column to see each processes command line arguments to find the process that you are interested in.\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/AttachToProcess.png\"><img decoding=\"async\" width=\"567\" height=\"403\" class=\"size-full wp-image-27615 aligncenter\" alt=\"Attach to process dialog showing a list of process from a remote Linux machine over an SSH transport.\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/AttachToProcess.png\" \/><\/a><\/li>\n<li>Click \u2018Attach\u2019. You will get a dialog to select which type of code you would like to debug. Pick \u2018Managed (.NET Core for Unix)\u2019.<\/li>\n<li>Debug as you would expect<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/DebuggerStopped.png\"><img decoding=\"async\" width=\"671\" height=\"484\" class=\"size-full wp-image-27616 aligncenter\" alt=\"A picture showing Visual Studio stopped at a breakpoint hit in code running on a remote Linuc machine.\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/DebuggerStopped.png\" \/><\/a><\/p>\n<p>If you have any feedback we\u2019d love to hear from you, send it from the VS Send Feedback feature or find us on twitter at <a href=\"https:\/\/twitter.com\/VS_Debugger\">@VS_Debugger<\/a>.<\/p>\n<p><strong>Gregg Miskelly<\/strong>\nPrincipal Software Engineerunzip curl<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the release of Visual Studio 2017 RC3 it is now possible to attach to .NET Core processes running on Linux over SSH. This blog post will explain how to set this up. Machine Setup On the Visual Studio computer, you need to install either the &#8216;ASP.NET and web development&#8217; or the &#8220;.NET Core cross-platform [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,225,249],"tags":[],"class_list":["post-52421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-git","category-open-source"],"acf":[],"blog_post_summary":"<p>With the release of Visual Studio 2017 RC3 it is now possible to attach to .NET Core processes running on Linux over SSH. This blog post will explain how to set this up. Machine Setup On the Visual Studio computer, you need to install either the &#8216;ASP.NET and web development&#8217; or the &#8220;.NET Core cross-platform [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/52421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=52421"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/52421\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=52421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=52421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=52421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}