Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oryx Issue #1181

Merged
merged 9 commits into from
Dec 3, 2024
29 changes: 15 additions & 14 deletions src/oryx/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,25 @@ DOTNET_BINARY=""

if dotnet --version > /dev/null ; then
DOTNET_BINARY=$(which dotnet)
RUNTIME_VERSIONS=$(dotnet --list-runtimes | awk '{print $2}' | sort | uniq)
fi

MAJOR_VERSION_ID=$(echo $(dotnet --version) | cut -d . -f 1)
PATCH_VERSION_ID=$(echo $(dotnet --version) | cut -d . -f 3)

PINNED_SDK_VERSION=""
# Oryx needs to be built with .NET 8
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ge "101" ]] ; then
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ne "202" ]] ; then
Mathiyarasy marked this conversation as resolved.
Show resolved Hide resolved
echo "'dotnet 8' was not detected. Attempting to install .NET 8 to build oryx."

# The oryx build fails with .Net 8.0.201, see https://github.com/devcontainers/images/issues/974
# Pinning it to a working version until the upstream Oryx repo updates the dependency
# install_dotnet_using_apt
PINNED_SDK_VERSION="8.0.101"
PINNED_SDK_VERSION="8.0.202"
install_dotnet_with_script ${PINNED_SDK_VERSION}

if ! dotnet --version > /dev/null ; then
echo "(!) Please install Dotnet before installing Oryx"
exit 1
fi

fi

BUILD_SCRIPT_GENERATOR=/usr/local/buildscriptgen
Expand All @@ -192,8 +190,8 @@ echo "Building solution '$SOLUTION_FILE_NAME'..."
cd $GIT_ORYX
${DOTNET_BINARY} build "$SOLUTION_FILE_NAME" -c Debug

${DOTNET_BINARY} publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj
${DOTNET_BINARY} publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj
${DOTNET_BINARY} publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj --self-contained true
Mathiyarasy marked this conversation as resolved.
Show resolved Hide resolved
${DOTNET_BINARY} publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj --self-contained true
Mathiyarasy marked this conversation as resolved.
Show resolved Hide resolved

chmod a+x ${BUILD_SCRIPT_GENERATOR}/GenerateBuildScript

Expand Down Expand Up @@ -236,16 +234,19 @@ fi
if [[ "${PINNED_SDK_VERSION}" != "" ]]; then
rm -f ${GIT_ORYX}/global.json
rm -rf /usr/share/dotnet/sdk/$PINNED_SDK_VERSION

# Extract the major, minor version and the first digit of the patch version
MAJOR_MINOR_PATCH1_VERSION=${PINNED_SDK_VERSION%??}
rm -rf /usr/share/dotnet/shared/Microsoft.NETCore.App/$MAJOR_MINOR_PATCH1_VERSION
rm -rf /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$MAJOR_MINOR_PATCH1_VERSION
rm -rf /usr/share/dotnet/templates/$MAJOR_MINOR_PATCH1_VERSION
NEW_RUNTIME_VERSIONS=$(dotnet --list-runtimes | awk '{print $2}' | sort | uniq)
if [ -n "${RUNTIME_VERSIONS:-}" ]; then
eljog marked this conversation as resolved.
Show resolved Hide resolved
SDK_INSTALLED_RUNTIME=$(echo "$NEW_RUNTIME_VERSIONS" | grep -vxFf <(echo "$RUNTIME_VERSIONS"))
else
SDK_INSTALLED_RUNTIME="$NEW_RUNTIME_VERSIONS"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where more than one sdk is installed? I see plural NEW_RUNTIME_VERSIONS
In that case SDK_INSTALLED_RUNTIME may get assigned a multiline string? Wouldn't that case issues with deletions on the lines below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we install only one sdk as a part of oryx and this is installing only one runtime
It is in plural because for images with dotnet even before oryx they sometime might have multiple runtimes from those runtimes we pick only the runtime installed from oryx feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case should the naming be updated to avoid the confusion?
I will go ahead and checkin this PR, you may followup with a PR if needed

fi
rm -rf /usr/share/dotnet/shared/Microsoft.NETCore.App/$SDK_INSTALLED_RUNTIME
rm -rf /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$SDK_INSTALLED_RUNTIME
rm -rf /usr/share/dotnet/templates/$SDK_INSTALLED_RUNTIME
fi


# Clean up
rm -rf /var/lib/apt/lists/*

echo "Done!"
echo "Done!"
Loading