Skip to content

Commit

Permalink
Oryx: Fix build failures ; pin to .NET 8.0.101 (#882)
Browse files Browse the repository at this point in the history
* Oryx: Fix build failures ; pin to .NET 8.0.101

* fix build

* fix "install_dotnet_and_oryx"
  • Loading branch information
samruddhikhandale authored Feb 27, 2024
1 parent 979c12b commit 0604e45
Show file tree
Hide file tree
Showing 5 changed files with 1,921 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/update-dotnet-install-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
set -e
echo "Start."
# Update dotnet-install for Oryx Feature as well
cp src/dotnet/scripts/vendor/dotnet-install.sh src/oryx/scripts/vendor/dotnet-install.sh
# Configure git and Push updates
git config --global user.email github-actions@github.com
git config --global user.name github-actions
Expand All @@ -36,12 +39,18 @@ jobs:
# Add / update and commit
git add src/dotnet/scripts/vendor/dotnet-install.sh
git add src/dotnet/scripts/vendor/dotnet-install.sh
git commit -m 'Automated dotnet-install script update' || export NO_UPDATES=true
# Bump version and push
if [ "$NO_UPDATES" != "true" ] ; then
echo "$(jq --indent 4 '.version = (.version | split(".") | map(tonumber) | .[2] += 1 | join("."))' src/dotnet/devcontainer-feature.json)" > src/dotnet/devcontainer-feature.json
git add src/dotnet/devcontainer-feature.json
echo "$(jq --indent 4 '.version = (.version | split(".") | map(tonumber) | .[2] += 1 | join("."))' src/oryx/devcontainer-feature.json)" > src/oryx/devcontainer-feature.json
git add src/oryx/devcontainer-feature.json
git commit -m 'Bump version'
git push origin "$branch"
gh api \
Expand Down
2 changes: 1 addition & 1 deletion src/oryx/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "oryx",
"version": "1.2.0",
"version": "1.3.0",
"name": "Oryx",
"description": "Installs the oryx CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx",
Expand Down
43 changes: 40 additions & 3 deletions src/oryx/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ check_packages() {
fi
}

install_dotnet_with_script()
{
local version="$1"
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
DOTNET_INSTALL_SCRIPT="$CURRENT_DIR/scripts/vendor/dotnet-install.sh"
DOTNET_INSTALL_DIR='/usr/share/dotnet'

check_packages icu-devtools

"$DOTNET_INSTALL_SCRIPT" \
--version "$version" \
--install-dir "$DOTNET_INSTALL_DIR" \
--no-path

DOTNET_BINARY="dotnet"
export PATH="${PATH}:/usr/share/dotnet"
DOTNET_BINARY_INSTALLATION="/usr/share/dotnet/sdk/${version}"
}

install_dotnet_using_apt() {
echo "Attempting to auto-install dotnet..."
install_from_microsoft_feed=false
Expand All @@ -86,6 +105,7 @@ install_dotnet_using_apt() {
DOTNET_SKIP_FIRST_TIME_EXPERIENCE="true" apt-get install -yq $DOTNET_INSTALLATION_PACKAGE
fi

DOTNET_BINARY="/usr/bin/dotnet"
echo -e "Finished attempt to install dotnet. Sdks installed:\n"
dotnet --list-sdks

Expand Down Expand Up @@ -126,25 +146,31 @@ usermod -a -G oryx "${USERNAME}"

# Required to decide if we want to clean up dotnet later.
DOTNET_INSTALLATION_PACKAGE=""
DOTNET_BINARY_INSTALLATION=""
DOTNET_BINARY=""

if dotnet --version > /dev/null ; then
DOTNET_BINARY=$(which dotnet)
fi

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

# Oryx needs to be built with .NET 8
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] ; then
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ge "101" ]] ; then
echo "'dotnet 8' was not detected. Attempting to install .NET 8 to build oryx."
install_dotnet_using_apt

# 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"
install_dotnet_with_script ${PINNED_SDK_VERSION}

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

DOTNET_BINARY="/usr/bin/dotnet"
fi

BUILD_SCRIPT_GENERATOR=/usr/local/buildscriptgen
Expand All @@ -156,6 +182,11 @@ mkdir -p ${ORYX}

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

if [[ "${DOTNET_BINARY_INSTALLATION}" != "" ]]; then
cd $GIT_ORYX
dotnet new globaljson --sdk-version ${PINNED_SDK_VERSION}
fi

SOLUTION_FILE_NAME="Oryx.sln"
echo "Building solution '$SOLUTION_FILE_NAME'..."

Expand Down Expand Up @@ -203,6 +234,12 @@ if [[ "${DOTNET_INSTALLATION_PACKAGE}" != "" ]]; then
apt purge -yq $DOTNET_INSTALLATION_PACKAGE
fi

if [[ "${DOTNET_BINARY_INSTALLATION}" != "" ]]; then
rm -f ${GIT_ORYX}/global.json
rm -rf ${DOTNET_BINARY_INSTALLATION}
fi


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

Expand Down
27 changes: 27 additions & 0 deletions src/oryx/scripts/vendor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### **IMPORTANT NOTE**

Scripts in this directory are sourced externally and not maintained by the Dev Container spec maintainers. Do not make changes directly as they might be overwritten at any moment.

## dotnet-install.sh

`dotnet-install.sh` is a copy of <https://dot.net/v1/dotnet-install.sh>. ([Script reference](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script))

Quick options reminder for `dotnet-install.sh`:

- `--version`: `"latest"` (default) or an exact version in the form A.B.C like `"6.0.413"`
- `--channel`: `"LTS"` (default), `"STS"`, a two-part version in the form A.B like `"6.0"` or three-part form A.B.Cxx like `"6.0.1xx"`
- `--quality`: `"daily"`, `"preview"` or `"GA"`
- The channel option is only used when version is 'latest' because an exact version overrides the channel option
- The quality option is only used when channel is 'A.B' or 'A.B.Cxx' because it can't be used with STS or LTS

Examples

```
dotnet-install.sh [--version latest] [--channel LTS]
dotnet-install.sh [--version latest] --channel STS
dotnet-install.sh [--version latest] --channel 6.0 [--quality GA]
dotnet-install.sh [--version latest] --channel 6.0.4xx [--quality GA]
dotnet-install.sh [--version latest] --channel 8.0 --quality preview
dotnet-install.sh [--version latest] --channel 8.0 --quality daily
dotnet-install.sh --version 6.0.413
```
Loading

0 comments on commit 0604e45

Please sign in to comment.