Skip to content

Commit 0604e45

Browse files
Oryx: Fix build failures ; pin to .NET 8.0.101 (#882)
* Oryx: Fix build failures ; pin to .NET 8.0.101 * fix build * fix "install_dotnet_and_oryx"
1 parent 979c12b commit 0604e45

5 files changed

Lines changed: 1921 additions & 4 deletions

File tree

.github/workflows/update-dotnet-install-script.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
set -e
2626
echo "Start."
2727
28+
# Update dotnet-install for Oryx Feature as well
29+
cp src/dotnet/scripts/vendor/dotnet-install.sh src/oryx/scripts/vendor/dotnet-install.sh
30+
2831
# Configure git and Push updates
2932
git config --global user.email github-actions@github.com
3033
git config --global user.name github-actions
@@ -36,12 +39,18 @@ jobs:
3639
3740
# Add / update and commit
3841
git add src/dotnet/scripts/vendor/dotnet-install.sh
42+
git add src/dotnet/scripts/vendor/dotnet-install.sh
43+
3944
git commit -m 'Automated dotnet-install script update' || export NO_UPDATES=true
4045
4146
# Bump version and push
4247
if [ "$NO_UPDATES" != "true" ] ; then
4348
echo "$(jq --indent 4 '.version = (.version | split(".") | map(tonumber) | .[2] += 1 | join("."))' src/dotnet/devcontainer-feature.json)" > src/dotnet/devcontainer-feature.json
4449
git add src/dotnet/devcontainer-feature.json
50+
51+
echo "$(jq --indent 4 '.version = (.version | split(".") | map(tonumber) | .[2] += 1 | join("."))' src/oryx/devcontainer-feature.json)" > src/oryx/devcontainer-feature.json
52+
git add src/oryx/devcontainer-feature.json
53+
4554
git commit -m 'Bump version'
4655
git push origin "$branch"
4756
gh api \

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.2.0",
3+
"version": "1.3.0",
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: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ check_packages() {
7070
fi
7171
}
7272

73+
install_dotnet_with_script()
74+
{
75+
local version="$1"
76+
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
77+
DOTNET_INSTALL_SCRIPT="$CURRENT_DIR/scripts/vendor/dotnet-install.sh"
78+
DOTNET_INSTALL_DIR='/usr/share/dotnet'
79+
80+
check_packages icu-devtools
81+
82+
"$DOTNET_INSTALL_SCRIPT" \
83+
--version "$version" \
84+
--install-dir "$DOTNET_INSTALL_DIR" \
85+
--no-path
86+
87+
DOTNET_BINARY="dotnet"
88+
export PATH="${PATH}:/usr/share/dotnet"
89+
DOTNET_BINARY_INSTALLATION="/usr/share/dotnet/sdk/${version}"
90+
}
91+
7392
install_dotnet_using_apt() {
7493
echo "Attempting to auto-install dotnet..."
7594
install_from_microsoft_feed=false
@@ -86,6 +105,7 @@ install_dotnet_using_apt() {
86105
DOTNET_SKIP_FIRST_TIME_EXPERIENCE="true" apt-get install -yq $DOTNET_INSTALLATION_PACKAGE
87106
fi
88107

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

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

127147
# Required to decide if we want to clean up dotnet later.
128148
DOTNET_INSTALLATION_PACKAGE=""
149+
DOTNET_BINARY_INSTALLATION=""
129150
DOTNET_BINARY=""
130151

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

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

137159
# Oryx needs to be built with .NET 8
138-
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] ; then
160+
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ge "101" ]] ; then
139161
echo "'dotnet 8' was not detected. Attempting to install .NET 8 to build oryx."
140-
install_dotnet_using_apt
162+
163+
# The oryx build fails with .Net 8.0.201, see https://github.com/devcontainers/images/issues/974
164+
# Pinning it to a working version until the upstream Oryx repo updates the dependency
165+
# install_dotnet_using_apt
166+
PINNED_SDK_VERSION="8.0.101"
167+
install_dotnet_with_script ${PINNED_SDK_VERSION}
141168

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

147-
DOTNET_BINARY="/usr/bin/dotnet"
148174
fi
149175

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

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

185+
if [[ "${DOTNET_BINARY_INSTALLATION}" != "" ]]; then
186+
cd $GIT_ORYX
187+
dotnet new globaljson --sdk-version ${PINNED_SDK_VERSION}
188+
fi
189+
159190
SOLUTION_FILE_NAME="Oryx.sln"
160191
echo "Building solution '$SOLUTION_FILE_NAME'..."
161192

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

237+
if [[ "${DOTNET_BINARY_INSTALLATION}" != "" ]]; then
238+
rm -f ${GIT_ORYX}/global.json
239+
rm -rf ${DOTNET_BINARY_INSTALLATION}
240+
fi
241+
242+
206243
# Clean up
207244
rm -rf /var/lib/apt/lists/*
208245

src/oryx/scripts/vendor/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### **IMPORTANT NOTE**
2+
3+
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.
4+
5+
## dotnet-install.sh
6+
7+
`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))
8+
9+
Quick options reminder for `dotnet-install.sh`:
10+
11+
- `--version`: `"latest"` (default) or an exact version in the form A.B.C like `"6.0.413"`
12+
- `--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"`
13+
- `--quality`: `"daily"`, `"preview"` or `"GA"`
14+
- The channel option is only used when version is 'latest' because an exact version overrides the channel option
15+
- 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
16+
17+
Examples
18+
19+
```
20+
dotnet-install.sh [--version latest] [--channel LTS]
21+
dotnet-install.sh [--version latest] --channel STS
22+
dotnet-install.sh [--version latest] --channel 6.0 [--quality GA]
23+
dotnet-install.sh [--version latest] --channel 6.0.4xx [--quality GA]
24+
dotnet-install.sh [--version latest] --channel 8.0 --quality preview
25+
dotnet-install.sh [--version latest] --channel 8.0 --quality daily
26+
dotnet-install.sh --version 6.0.413
27+
```

0 commit comments

Comments
 (0)