Skip to content

Commit e3a0f0d

Browse files
committed
install from source: add support for Jammy Jellyfish
The dotnet team recently added support for installing natively from Jammy feeds on Ubuntu 22.04: dotnet/core#7699 This unfortunately created problems with our current install from source script, as it caused conflicts with the packages.microsoft.com feed we use for Debian/Ubuntu. This change modifies the Debian/Ubuntu dotnet install process to install from Jammy feeds for users on Ubuntu 22.04 and greater while continuing to use the packages.microsoft.com feed for Debian and older Ubuntu versions.
1 parent a9fcb46 commit e3a0f0d

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/linux/Packaging.Linux/install-from-source.sh

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ add_to_PATH () {
103103
done
104104
}
105105

106+
apt_install() {
107+
pkg_name=$1
108+
109+
$sudo_cmd apt update
110+
$sudo_cmd apt install $pkg_name -y 2>/dev/null
111+
}
112+
106113
sudo_cmd=
107114

108115
# if the user isn't root, we need to use `sudo` for certain commands
@@ -120,22 +127,27 @@ case "$distribution" in
120127
$sudo_cmd apt update
121128
install_shared_packages apt install
122129

123-
# add dotnet package repository/signing key
124-
$sudo_cmd apt update && $sudo_cmd apt install wget -y
125-
curl -LO https://packages.microsoft.com/config/"$distribution"/"$version"/packages-microsoft-prod.deb
126-
$sudo_cmd dpkg -i packages-microsoft-prod.deb
127-
rm packages-microsoft-prod.deb
128-
129-
# proactively install tzdata to prevent prompts
130-
export DEBIAN_FRONTEND=noninteractive
131-
$sudo_cmd apt install -y --no-install-recommends tzdata
132-
133130
# install dotnet packages and dependencies if needed
134131
if [ -z "$(verify_existing_dotnet_installation)" ]; then
135-
$sudo_cmd apt update
136-
$sudo_cmd apt install apt-transport-https -y
137-
$sudo_cmd apt update
138-
$sudo_cmd apt install dotnet-sdk-6.0 dpkg-dev -y
132+
# First try to use native feeds (Ubuntu 22.04 and later).
133+
if ! apt_install dotnet6; then
134+
# If the native feeds fail, we fall back to
135+
# packages.microsoft.com. We begin by adding the dotnet package
136+
# repository/signing key.
137+
$sudo_cmd apt update && $sudo_cmd apt install wget -y
138+
curl -LO https://packages.microsoft.com/config/"$distribution"/"$version"/packages-microsoft-prod.deb
139+
$sudo_cmd dpkg -i packages-microsoft-prod.deb
140+
rm packages-microsoft-prod.deb
141+
142+
# Proactively install tzdata to prevent prompts.
143+
export DEBIAN_FRONTEND=noninteractive
144+
$sudo_cmd apt install -y --no-install-recommends tzdata
145+
146+
$sudo_cmd apt update
147+
$sudo_cmd apt install apt-transport-https -y
148+
$sudo_cmd apt update
149+
$sudo_cmd apt install dotnet-sdk-6.0 dpkg-dev -y
150+
fi
139151
fi
140152
;;
141153
linuxmint)

0 commit comments

Comments
 (0)