dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.06k forks source link

Cannot install maui-android workload on Ubuntu 24.04 in Docker #41123

Closed klemmchr closed 3 months ago

klemmchr commented 3 months ago

Description

I try to install the maui-android workload on Ubuntu 24.04 in Docker. The installation fails because the workload could not be found. Installing other workloads (like wasm-tools) works without any error.

FROM ubuntu:noble

RUN apt update
RUN apt install -y dotnet-sdk-8.0
RUN dotnet workload install maui-android

Console output

 > [4/4] RUN dotnet workload install maui-android:
0.372
0.373 Welcome to .NET 8.0!
0.373 ---------------------
0.373 SDK Version: 8.0.105
0.520
0.520 ----------------
0.520 Installed an ASP.NET Core HTTPS development certificate.
0.520 To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux
0.521
0.521 ----------------
0.521 Write your first app: https://aka.ms/dotnet-hello-world
0.521 Find out what's new: https://aka.ms/dotnet-whats-new
0.521 Explore documentation: https://aka.ms/dotnet-docs
0.521 Report issues and find source on GitHub: https://github.com/dotnet/core
0.521 Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
0.521 --------------------------------------------------------------------------------------
0.590 Workload ID maui-android is not recognized.

Steps to Reproduce

Use Dockerfile from above and build it

Link to public reproduction project repository

No response

Version with bug

Unknown/Other

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Other (Tizen, Linux, etc. not supported by Microsoft directly)

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

drasticactions commented 3 months ago

@jonathanpeppers Is there a maui-android workload for Linux?

klemmchr commented 3 months ago

There is for jammy. We are using 22.04 right now and it can be installed without any issue.

baronfel commented 3 months ago

@klemmchr you're using the distro-built SDKs, not the MS-provided SDKs, right? In that case you're hitting https://github.com/dotnet/source-build/issues/3242. We're working with the MAUI teams to make their workloads compatible with the Source-Built SDKs (which the distros use) but for now there's not really a great workaround that doesn't involve mucking around in your SDK install. Please follow that issue for updates.

akoeplinger commented 3 months ago

An alternative is to install the Microsoft build of the SDK manually from the .tar.gz as detailed in https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#manual-install

klemmchr commented 3 months ago

@baronfel I can reproduce this issue using the MS-provided SDKs.

This is a sample Dockerfile for jammy (working):

FROM ubuntu:jammy

ENV \
    # UID of the non-root user 'app'
    APP_UID=1654 \
    # Configure web servers to bind to port 8080 when present
    ASPNETCORE_HTTP_PORTS=8080 \
    # Enable detection of running in a container
    DOTNET_RUNNING_IN_CONTAINER=true \
    # Add global tools to path
    PATH=/root/.dotnet/tools:$PATH \
    # Do not generate dev certificates
    DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
    # Do not show first run text
    DOTNET_NOLOGO=true \
    # Use polling file watcher
    DOTNET_USE_POLLING_FILE_WATCHER=true

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        wget \
        libatomic1 \
        libc6 \
        libgcc-s1 \
        libgssapi-krb5-2 \
        libicu70 \
        liblttng-ust1 \
        libssl3 \
        libstdc++6 \
        libunwind8 \
        tzdata \
        zlib1g \
    && rm -rf /var/lib/apt/lists/*

RUN 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 update && \
    apt install -y dotnet-sdk-8.0 && \
    rm -rf /var/lib/apt/lists/*

RUN dotnet workload install maui-android

This is a sample Dockerfile for noble (not working):

FROM ubuntu:noble

ENV \
    # UID of the non-root user 'app'
    APP_UID=1654 \
    # Configure web servers to bind to port 8080 when present
    ASPNETCORE_HTTP_PORTS=8080 \
    # Enable detection of running in a container
    DOTNET_RUNNING_IN_CONTAINER=true \
    # Add global tools to path
    PATH=/root/.dotnet/tools:$PATH \
    # Do not generate dev certificates
    DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
    # Do not show first run text
    DOTNET_NOLOGO=true \
    # Use polling file watcher
    DOTNET_USE_POLLING_FILE_WATCHER=true

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        wget \
        libc6 \
        libgcc-s1 \
        libicu74 \
        liblttng-ust1 \
        libssl3 \
        libstdc++6 \
        libunwind8 \
        tzdata \
        zlib1g \
    && rm -rf /var/lib/apt/lists/*

RUN wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
    dpkg -i packages-microsoft-prod.deb && \
    rm packages-microsoft-prod.deb && \
    apt update && \
    apt install -y dotnet-sdk-8.0 && \
    rm -rf /var/lib/apt/lists/*

RUN dotnet workload install maui-android

I cannot say for sure that the MS-provided SDKs are even installed on noble. According to the docs there is no Microsoft feed for noble.

Installing .NET via manual install is not an option to me. I need a solution where the latest SDK gets installed automatically without manual configuration from my side.

akoeplinger commented 3 months ago

I cannot say for sure that the MS-provided SDKs are even installed on noble.

Correct, the packages.microsoft.com repo for Ubuntu 24.04 doesn't contain 8.0 SDKs so you're installing from Ubuntu's repo: https://packages.microsoft.com/ubuntu/24.04/prod/pool/main/d/

Installing .NET via manual install is not an option to me. I need a solution where the latest SDK gets installed automatically without manual configuration from my side.

You could use the dotnet-install.sh script which handles installing the latest version: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install

klemmchr commented 3 months ago

Correct, the packages.microsoft.com repo for Ubuntu 24.04 doesn't contain 8.0 SDKs so you're installing from Ubuntu's repo: https://packages.microsoft.com/ubuntu/24.04/prod/pool/main/d/

Why is Microsoft not publishing the 8.0 SDKs in their repo, especially when the distro-build SDKs are not suited for installing certain workloads?

You could use the dotnet-install.sh script which handles installing the latest version: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install

Using magic install scripts in Dockerfiles is heavily discouraged since it poses a security risk and makes the installation intransparent.

akoeplinger commented 3 months ago

Why is Microsoft not publishing the 8.0 SDKs in their repo, especially when the distro-build SDKs are not suited for installing certain workloads?

There's more background in https://github.com/dotnet/core/discussions/9258. I wasn't involved in the discussions so I'm not sure people were aware of the MAUI workloads limitation.

Using magic install scripts in Dockerfiles is heavily discouraged since it poses a security risk and makes the installation intransparent.

You can read the source of the script, it essentially downloads and unpacks the .tar.gz, which is why I suggested the manual install 😄 But anyway this was meant to give a workaround, the real fix is putting the workload manifests into source-built SDKs: https://github.com/dotnet/source-build/issues/3242