Skip to content

Commit 084df81

Browse files
Oryx: Clean up additional installation of .NET (#892)
1 parent 025cae1 commit 084df81

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/oryx/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "oryx",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"name": "Oryx",
55
"description": "Installs the oryx CLI",
66
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx",

src/oryx/install.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ install_dotnet_with_script()
8686

8787
DOTNET_BINARY="dotnet"
8888
export PATH="${PATH}:/usr/share/dotnet"
89-
DOTNET_BINARY_INSTALLATION="/usr/share/dotnet/sdk/${version}"
9089
}
9190

9291
install_dotnet_using_apt() {
@@ -146,7 +145,6 @@ usermod -a -G oryx "${USERNAME}"
146145

147146
# Required to decide if we want to clean up dotnet later.
148147
DOTNET_INSTALLATION_PACKAGE=""
149-
DOTNET_BINARY_INSTALLATION=""
150148
DOTNET_BINARY=""
151149

152150
if dotnet --version > /dev/null ; then
@@ -156,6 +154,7 @@ fi
156154
MAJOR_VERSION_ID=$(echo $(dotnet --version) | cut -d . -f 1)
157155
PATCH_VERSION_ID=$(echo $(dotnet --version) | cut -d . -f 3)
158156

157+
PINNED_SDK_VERSION=""
159158
# Oryx needs to be built with .NET 8
160159
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ge "101" ]] ; then
161160
echo "'dotnet 8' was not detected. Attempting to install .NET 8 to build oryx."
@@ -182,7 +181,7 @@ mkdir -p ${ORYX}
182181

183182
git clone --depth=1 https://github.com/microsoft/Oryx $GIT_ORYX
184183

185-
if [[ "${DOTNET_BINARY_INSTALLATION}" != "" ]]; then
184+
if [[ "${PINNED_SDK_VERSION}" != "" ]]; then
186185
cd $GIT_ORYX
187186
dotnet new globaljson --sdk-version ${PINNED_SDK_VERSION}
188187
fi
@@ -234,9 +233,14 @@ if [[ "${DOTNET_INSTALLATION_PACKAGE}" != "" ]]; then
234233
apt purge -yq $DOTNET_INSTALLATION_PACKAGE
235234
fi
236235

237-
if [[ "${DOTNET_BINARY_INSTALLATION}" != "" ]]; then
236+
if [[ "${PINNED_SDK_VERSION}" != "" ]]; then
238237
rm -f ${GIT_ORYX}/global.json
239-
rm -rf ${DOTNET_BINARY_INSTALLATION}
238+
rm -rf /usr/share/dotnet/sdk/$PINNED_SDK_VERSION
239+
240+
# Extract the major, minor version and the first digit of the patch version
241+
MAJOR_MINOR_PATCH1_VERSION=${PINNED_SDK_VERSION%??}
242+
rm -rf /usr/share/dotnet/shared/Microsoft.NETCore.App/$MAJOR_MINOR_PATCH1_VERSION
243+
rm -rf /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$MAJOR_MINOR_PATCH1_VERSION
240244
fi
241245

242246

test/oryx/install_dotnet_and_oryx.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Runtimes are listed twice due to 'Microsoft.NETCore.App' and 'Microsoft.AspNetCore.App'
9+
check "two versions of dotnet runtimes are present" bash -c "[ $(dotnet --list-runtimes | wc -l) -eq 4 ]"
10+
811
check "Oryx version" oryx --version
912
check "Dotnet is not removed if it is not installed by the Oryx Feature" dotnet --version
1013

0 commit comments

Comments
 (0)