@@ -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
9291install_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.
148147DOTNET_INSTALLATION_PACKAGE=" "
149- DOTNET_BINARY_INSTALLATION=" "
150148DOTNET_BINARY=" "
151149
152150if dotnet --version > /dev/null ; then
156154MAJOR_VERSION_ID=$( echo $( dotnet --version) | cut -d . -f 1)
157155PATCH_VERSION_ID=$( echo $( dotnet --version) | cut -d . -f 3)
158156
157+ PINNED_SDK_VERSION=" "
159158# Oryx needs to be built with .NET 8
160159if [[ " ${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
183182git 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}
188187fi
@@ -234,9 +233,14 @@ if [[ "${DOTNET_INSTALLATION_PACKAGE}" != "" ]]; then
234233 apt purge -yq $DOTNET_INSTALLATION_PACKAGE
235234fi
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
240244fi
241245
242246
0 commit comments