microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

Unable to debug "dotnet/aspnet:6.0-alpine" with "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false" #347

Closed FHFS closed 2 years ago

FHFS commented 2 years ago

Hello,

We are trying to debug our project, but we are having trouble debugging. Our project requires "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false" and "dotnet/aspnet:6.0-alpine" Our container runs fine with that environment variable set. However we get an error when starting the debugger.

One or more errors occurred.
Failed to launch debug adapter. Addition information may be available in the output window.
The Operation was canceled.

When we set "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true", we are able to start the debug tool.

How do we fix this?

NCarlsonMSFT commented 2 years ago

As noted in https://github.com/dotnet/runtime/issues/11736 the Alpine image has DOTNET_SYSTEM_GLOBALIZATION_INVARIANT set to false b/c the base image does not have icu_libs. You can install that in your image to unblock debugging.

FHFS commented 2 years ago

I have installed icu-lib, and it is working correctly in the container. The problem is with the debugging tool, it exits when I try to debug an image with DOTNET_SYSTEM_GLOBALIZATION_INVARIANT set to true.

NCarlsonMSFT commented 2 years ago

I am unable to reproduce that localy once I've installed icu-libs. Can you provide a minified repro?

For reference here is my test Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base
RUN apk update; apk add icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /src
COPY ["WebApplication20/WebApplication20.csproj", "WebApplication20/"]
RUN dotnet restore "WebApplication20/WebApplication20.csproj"
COPY . .
WORKDIR "/src/WebApplication20"
RUN dotnet build "WebApplication20.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "WebApplication20.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication20.dll"]
FHFS commented 2 years ago

I also made a sample project where I did install ICU-LIBS and set the env variable. Where I was able to debug with "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT true" set in the docker-compose file, debugging failed with it set to false.

Yesterday I updated Docker and VisualStudio(Preview), and now I am just unable to debug docker images. Base images and alpine images, with or without icu-libs and globalization invariant.

I just reinstalled Visual Studio community (Normal, not Preview) and it still does not work. I only get the error "Failed to launch debug adapter".

edit must have been a VisualStudio Preview problem. restarted and now I can debug again.