Skip to content

Commit 0921f2f

Browse files
author
Your Name
committed
add devcontainer based on mcr.microsoft.com/dotnet/sdk
1 parent 3496035 commit 0921f2f

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
ARG DOTNET_VERSION="7.0"
2+
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS dotnet-maui-android
3+
4+
ARG MAINTAINER
5+
ARG TZ="UTC"
6+
7+
LABEL maintainer=${MAINTAINER}
8+
ENV TZ=${TZ}
9+
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
10+
11+
# NET SDK
12+
ENV \
13+
# Unset ASPNETCORE_URLS from aspnet base image
14+
ASPNETCORE_URLS= \
15+
# Do not generate certificate
16+
DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
17+
# Do not show first run text
18+
DOTNET_NOLOGO=true \
19+
# Enable correct mode for dotnet watch (only mode supported in a container)
20+
DOTNET_USE_POLLING_FILE_WATCHER=true \
21+
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
22+
NUGET_XMLDOC_MODE=skip
23+
24+
RUN apt-get update \
25+
&& apt-get install -y --no-install-recommends \
26+
ca-certificates \
27+
curl \
28+
git \
29+
wget \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
# JAVA SDK
33+
ARG JAVA_VERSION="11"
34+
RUN <<EOF
35+
set -e
36+
echo "deb http://deb.debian.org/debian bullseye-backports main contrib" > /etc/apt/sources.list.d/bullseye-backports.list
37+
echo "deb-src http://deb.debian.org/debian bullseye-backports main contrib" >> /etc/apt/sources.list.d/bullseye-backports.list
38+
apt-get update
39+
apt-get install -t bullseye-backports -y openjdk-${JAVA_VERSION}-jdk-headless
40+
rm -rf /var/lib/apt/lists/*
41+
EOF
42+
43+
ENV JAVA_HOME=/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64/
44+
45+
# Android SDK Manager
46+
RUN <<EOF
47+
set -e
48+
echo "deb http://deb.debian.org/debian bullseye-backports main contrib" > /etc/apt/sources.list.d/bullseye-backports.list
49+
echo "deb-src http://deb.debian.org/debian bullseye-backports main contrib" >> /etc/apt/sources.list.d/bullseye-backports.list
50+
apt-get update
51+
apt-get install -t bullseye-backports -y sdkmanager
52+
rm -rf /var/lib/apt/lists/*
53+
EOF
54+
55+
ENV ANDROID_SDK_ROOT=/usr/lib/android-sdk
56+
57+
# Android toolchain
58+
ARG ANDROID_API="33"
59+
ARG BUILD_TOOLS_VERSION="33.0.2"
60+
RUN <<EOF
61+
set -e
62+
sdkmanager "platform-tools" "build-tools;${BUILD_TOOLS_VERSION}" "platforms;android-${ANDROID_API}"
63+
EOF
64+
65+
ARG MAUI_VERSION
66+
# MAUI (We can only install the latest version, the ARG is to cache bust if that version changed)
67+
RUN <<EOF
68+
set -e
69+
dotnet workload install maui-android
70+
EOF

.devcontainer/devcontainer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
3+
{
4+
"name": "C# (.NET) + MAUI",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
// "image": "mcr.microsoft.com/devcontainers/dotnet:1-7.0-bookworm",
7+
"build": {
8+
"dockerfile": "Dockerfile",
9+
"context": "..",
10+
// Update 'VARIANT' to pick a dotnet version. Rebuild the container
11+
"args": {
12+
// "TZ": "UTC",
13+
// // "MAUI_VERSION": "7.0.101",
14+
// "DOTNET_VERSION": "7.0",
15+
// "DOTNET_SDK_VERSION": "7.0.404",
16+
// "JAVA_VERSION": "11",
17+
// "ANDROID_API": "33",
18+
// "BUILD_TOOLS_VERSION": "33.0.2"
19+
}
20+
}
21+
// "settings": {
22+
// "overrideCommand": true
23+
// }
24+
25+
// "features": {
26+
// "ghcr.io/nordcominc/devcontainer-features/android-sdk:1": {}
27+
// }
28+
29+
// Features to add to the dev container. More info: https://containers.dev/features.
30+
// "features": {},
31+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
32+
// "forwardPorts": [5000, 5001],
33+
// "portsAttributes": {
34+
// "5001": {
35+
// "protocol": "https"
36+
// }
37+
// }
38+
// Use 'postCreateCommand' to run commands after the container is created.
39+
// "postCreateCommand": "dotnet restore",
40+
// Configure tool-specific properties.
41+
// "customizations": {},
42+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
43+
// "remoteUser": "root"
44+
}

0 commit comments

Comments
 (0)