Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug with docker containers #185

Closed
galvesribeiro opened this issue Jan 26, 2017 · 7 comments
Closed

Debug with docker containers #185

galvesribeiro opened this issue Jan 26, 2017 · 7 comments
Labels

Comments

@galvesribeiro
Copy link
Member

What is the proper way to install the debugger on a dotnet image and get it debugging from VSCode?

Currently there are multiple (messy) ways to work with old project.json and containers like for example, that bunch of scripts generated by yo docker.

Is there any guidance on how to create a debug container for .net apps?

Thank you

@MichaelSimons
Copy link
Member

@galvesribeiro, Good question. The yo docker experience is definitely out of date. We currently don't have any guidance on this. Let me dig around a little and see what I can come up with.

@galvesribeiro
Copy link
Member Author

galvesribeiro commented Jan 27, 2017

Thanks @MichaelSimons I appreciate that. I'm struggling to get it to work here. Even if I use VS2017 which has that Add Docker Support function, it works, but there is no docs on how that works whatsoever so I can't try reproduce it on VSCode. Looking forward to hear from you, thanks!

@MichaelSimons
Copy link
Member

MichaelSimons commented Jan 27, 2017

For my own exercise, I went through the yo docker experience. Even though it was out of date, I was able to get it working with a few tweaks.

  1. mkdir DockerDebugApp
  2. cd DockerDebugApp
  3. dotnet new -t Console1.1
  4. yo docker (used defaults)
  5. Ignore project.json file does not exist error
  6. Open DockerDebugAdd in VSCode
  7. add the following to the csproj
          <ItemGroup>
      <None Update="Dockerfile">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </None>
      <None Update="Dockerfile.Debug">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </None>
      <None Update="docker-compose.yml">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </None>
      <None Update="docker-compose.debug.yml">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </None>
    </ItemGroup>
    
  8. Update the two Dockerfiles to reference the appropriate base images
    a. microsoft/dotnet:1.1-sdk-msbuild
    b. microsoft/dotnet:1.1-runtime
  9. Update the Dockerfile.debug to install unzip before the GetClrDbg logic
        RUN apt-get update \
        && apt-get install -y --no-install-recommends \
            unzip \
        && rm -rf /var/lib/apt/lists/*
    
  10. Set the $framework variables of the dockerTask script to match your csproj
    a. netcoreapp1.1
  11. dotnet restore -r debian.8-x64
  12. Build
  13. Set breakpoint in program
  14. F5

@galvesribeiro
Copy link
Member Author

Was about to ping you... I did similar thing and it work :)

However, that is not close to what we have with VS2017, where you can run/debug multiple projects using the solution-level docker-compose files...

@MichaelSimons
Copy link
Member

I moved this to microsoft/generator-docker#130 since the underlying issue is not specific to the Docker image rather it is with the broken yo docker experience.

@dasMulli
Copy link
Contributor

@MichaelSimons most of the fuss is about downloading clrdbg into the containers. Does it make sense to create a public image that already includes the correct debugger? (e.g. microsoft/dotnet:1.1-sdk-msbuild-debug).

@galvesribeiro
Copy link
Member Author

@dasMulli if you look at simple apps with a single container yes, people don't know that the SDK doesn't come with the debugger. However, when you have multiple containers (i.e. docker-compose based projects) the problem goes far from just that. Look at the new issue @MichaelSimons just created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants