core
core copied to clipboard
Debugging not working after switching to Canonical DotNet packages
Description
DotNet Core debugger doesn't work any more after switching from the Microsoft repository to the Canonical repository for dotnet-skd-6.0 packages.
Project builds, runs tests, and can be run through dotnet run
.
When trying to start through VSC code launch button the project builds and seemingly starts, but the debugger fails to connect:
You may only use the Microsoft .NET Core Debugger (vsdbg) with Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you develop and test your applications.
Using launch settings from '/workspace/src/WebService/Properties/launchSettings.json' [Profile 'WebService']... Unable to attach to CoreCLR. Unknown Error: 0x80131c3c
The rest API then can also not be reached. The program does however terminate only after stopping debugging, implying it ran:
The program '[5224] WebService.dll' has exited with code -1 (0xffffffff).
Not sure if the mention of Mac is related as I'm using VSC on Windows10 (with WSL), and it's an Ubuntu container.
Configuration
Building project in dev-container in VisualStudioCode.
Relevant Dockerfile part:
#actually a internal, custom image, but it's based on ubuntu:22.04
FROM ubuntu:22.04 AS dev
USER root
# Install Azure CLI & Azure Artifacts Credential Provider
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y bash curl \
&& curl -sL https://aka.ms/InstallAzureCLIDeb | bash \
&& curl -sL https://aka.ms/install-artifacts-credprovider.sh | bash \
&& rm -rf /var/lib/apt/lists/*
# Install DotNet
RUN apt-get update && \
apt-get -y install dotnet-sdk-6.0 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
COPY . .
VSC launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "azLoginAndBuild",
"program": "${workspaceFolder}/src/WebService/bin/Debug/net6.0/WebService.dll",
"args": [],
"cwd": "${workspaceFolder}/src/WebService",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}/swagger",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}/swagger"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
Project launchsettings.json
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"WebService": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:44300;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
}
}
C# project is a simple ASPDotNet rest server (Micro-Service). Installed package version:
Package: dotnet-sdk-6.0 Versions: 6.0.108-0ubuntu1~22.04.1 (/var/lib/dpkg/status)
Regression?
Worked when installing dotnet package from the MS repository:
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y wget apt-transport-https \
&& wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt-get remove -y wget \
&& apt-get update \
&& apt-get install -y dotnet-sdk-6.0 \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="${PATH}:/root/.dotnet/tools"
Other information
The final stage of the same project has already been reverted to the MS repository package (which used the aspnet-runtime-6.0 package). There the project started, however SSL failed to connect killing the container. At the time it was believed the container was misconfigured by our CI. Now this implies to me some deeper underlying issue, making this not an SDK specific issue, hence the issue-ticket here.
any thoughts on this @mikem8361 ? I suspect that you may not get symbols unless you use MS binaries but I would expect at last debugger to start,
Someone from VS Code should look at this (not sure who). I'm not sure what "Canonical DotNet packages" means either. It looks you are using the Microsoft published SDK package (dotnet-sdk-6.0)?
I think those are packages build and published by Ubuntu22 release and not us. I vaguely remember some issues when mixing binaries but I'm not sure. cc: @tmds @omajid just in case.
@mikem8361 With Canonical DotNet packages I mean the packages hosted on the Canonical/Ubuntu repository. Reference: https://devblogs.microsoft.com/dotnet/dotnet-6-is-now-in-ubuntu-2204/
If they are not the MS official built binaries then the symbol and debugger files necessary to debug have not been published to the MS symbol servers. We don't support this scenario as far as I know.
I can debug .NET applications using source-built .NET on Fedora fine.
A known limitation is not being able to debug .NET itself due to missing debug information (source files, sourcelink, ...) as @mikem8361 said.
You mention containers and Dockerfiles. Where is the app you are trying to debug running?
Are you able to debug an app that runs natively (that is: without containers) on Ubuntu using Canonical packages?
If they are not the MS official built binaries then the symbol and debugger files necessary to debug have not been published to the MS symbol servers. We don't support this scenario as far as I know.
- What is the point of publishing an SDK that you can't debug?
- Why can't you publish the same binaries to two different repositories? Seems like a hassle to support two binaries of what should be the same thing.
You mention containers and Dockerfiles. Where is the app you are trying to debug running? Are you able to debug an app that runs natively
Well, the cloud. It's a mircro-service I'm developing locally in a VisualStudioCode DevContainer, normally running in a Azure Kubernetes cluster. I have no setup to test it natively right now, sorry (it's containers all the way down for us /s).
I'm trying to reproduce the issue.
VS Code generates a Dockerfile
for me like this:
FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
WORKDIR /app
EXPOSE 5000
EXPOSE 8000
ENV ASPNETCORE_URLS=http://+:5000
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
WORKDIR /src
COPY ["web.csproj", "./"]
RUN dotnet restore "web.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "web.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "web.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "web.dll"]
This uses the Microsoft base image. Using this image, debugging works from VS Code.
I now patch this Dockerfile
using the base and packages you've provided in the initial comment:
-FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
+FROM ubuntu:22.04 AS base
+
+RUN apt-get update && \
+apt-get -y install dotnet-sdk-6.0 && \
+rm -rf /var/lib/apt/lists/*
+
WORKDIR /app
When I debug this from VS Code, the debugger also works.
What stage is your devcontainer in (devcontainer.json)? It's probably in build which still gets its SDK from the source image. Base does not contain any source code (it does not have COPY . ., nor do I see a mount), so it can't be your working stage.
What stage is your devcontainer in (devcontainer.json)? It's probably in build which still gets its SDK from the source image. Base does not contain any source code (it does not have COPY . ., nor do I see a mount), so it can't be your working stage.
I don't have a devcontainer.json
file. My app is the ASP.NET Core Empty template with the Dockerfile
that VS Code generated (shown above).
The container VS Code is attaching to is called web-dev
. I can see it uses the image defined in the Dockerfile
:
$ podman exec -ti web-dev whoami
appuser
Are you doing a multi-stage build that copies the published application into another image than ubuntu:22.04
?
Can you suggest modifications to the Dockerfile
that allow me to reproduce the issue?
We're using multi-stage Dockerfiles, but the DevContainer only uses the first, dev, stage. You can try building the project in debug. What debugger are you connecting with?
I'm using VS Code with the latest version of the C# extension (v.1.25.0). Debugging a .NET app running in a container with the Ubuntu packages you've mentioned works for me without issue.
Then try to use my setup with devcontainer.
Can you create a GitHub repo with a devcontainer file, Dockerfile and an ASP.NET app that demonstrates the issue?
No follow up since August on @tmds' request. Closing.