Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

What to Do When Visual Studio 2017 Debugger Won’t Attach to Docker

DZone's Guide to

What to Do When Visual Studio 2017 Debugger Won’t Attach to Docker

I’m not sure if that’s the right solution, but since I was unable to find any other reference to this problem (let alone a solution), I wanted to write it down.

· DevOps Zone
Free Resource

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

We’ve been developing .NET Core micro-services for a few months. Obviously, we’ve decided to use Docker for Windows for deployment.

Don’t get me wrong — I still find the experience amazing. Write code and immediately debug your code running on Docker. It got to a point I no longer think about this amazing integration; write on Windows, deploy on Linux, and it just works.

It’s been a fun but a rocky ride. From time to time, we’ll get an update to Visual Studio, Docker, or both. Usually, it didn’t break anything, but when it did, it was very frustrating for the whole team.
The last hitch happened today when I needed to show something to a fellow developer. I pressed F5 like I always do and as I was preparing for a quick debug session, something bad happened, I got an error dialog claiming:

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use Microsoft.NETCoreApp 1.0.0 or newer. This may be expected if the target process did not run .NET code.

Since it worked yesterday (or at least the day before that), I’ve started thinking what could have caused this issue. I’ve found several suspects — Windows updated, Docker updated, Visual Studio released — in other words, everything that happened to my machine could be responsible (up to and including solar winds and Bigfoot).

I’ve tried updating the project NuGet references (not sure why) and checked with the other developers. Some didn’t install the latest and greatest (again not sure why). The conclusion was that all of our machines failed to debug the project we’ve been working on for the last two months.

So, it might be a bug in the project. Nope again! I’ve tried creating a new dummy project and found the same result.

Luckily, my co-worker took the time to read Visual Studio’s output window and found the following:

dockerissue
And then, something clicked in my head. Docker’s virtual machine was not updated for some reason. MobyLinuxVM, which Docker used to run our code, used an old .NET Core from our project — and since it could not run the code, we could not debug it.

But how can you update .NET Core on a virtual Linux machine? I still don’t have any idea. Instead, what we’ve ended up doing is go into Docker settings and cause it to rebuild the virtual machine by using Reset to factory defaults… as shown below:

resetdockerOnce MobyLinuxVM was re-created, debugging started working again.

I’m not sure if that’s the right solution, but since I was unable to find any other reference to this problem (let alone a solution), I wanted to write it down.

If you know of a better solution, please let me know.

And until then, happy coding!

Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.

Topics:
devops ,visual studio ,debug ,docker

Published at DZone with permission of Dror Helper, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}