Unverified Commit 05a4cbf9 authored by Steven's avatar Steven Committed by GitHub

dotnet: make 'dotnet' available to 'sudo' commands (#1007)

* dotnet: use predefined DOTNET_ROOT in install script

* dotnet: create symbolic link in /usr/bin

* dotnet: bump patch version

* dotnet: add test for install dir and symlink

* Remove unneeded --force
parent 1045404e
{ {
"id": "dotnet", "id": "dotnet",
"version": "2.1.0", "version": "2.1.1",
"name": "Dotnet CLI", "name": "Dotnet CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet",
"description": "This Feature installs the latest .NET SDK, which includes the .NET CLI and the shared runtime. Options are provided to choose a different version or additional versions.", "description": "This Feature installs the latest .NET SDK, which includes the .NET CLI and the shared runtime. Options are provided to choose a different version or additional versions.",
......
...@@ -128,6 +128,12 @@ if [ ${#workloads[@]} -ne 0 ]; then ...@@ -128,6 +128,12 @@ if [ ${#workloads[@]} -ne 0 ]; then
install_workloads "${workloads[@]}" install_workloads "${workloads[@]}"
fi fi
# Create a symbolic link '/usr/bin/dotnet', to make dotnet available to 'sudo'
# This is necessary because 'sudo' resets the PATH variable, so it won't search the DOTNET_ROOT directory
if [ ! -e /usr/bin/dotnet ]; then
ln --symbolic "$DOTNET_ROOT/dotnet" /usr/bin/dotnet
fi
# Clean up # Clean up
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
rm -rf scripts rm -rf scripts
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
# Maintainer: The Dev Container spec maintainers # Maintainer: The Dev Container spec maintainers
DOTNET_SCRIPTS=$(dirname "${BASH_SOURCE[0]}") DOTNET_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")
DOTNET_INSTALL_SCRIPT="$DOTNET_SCRIPTS/vendor/dotnet-install.sh" DOTNET_INSTALL_SCRIPT="$DOTNET_SCRIPTS/vendor/dotnet-install.sh"
DOTNET_INSTALL_DIR='/usr/share/dotnet'
# Prints the latest dotnet version in the specified channel # Prints the latest dotnet version in the specified channel
# Usage: fetch_latest_version_in_channel <channel> [<runtime>] # Usage: fetch_latest_version_in_channel <channel> [<runtime>]
...@@ -75,11 +74,11 @@ install_sdk() { ...@@ -75,11 +74,11 @@ install_sdk() {
fi fi
# Currently this script does not make it possible to qualify the version, 'GA' is always implied # Currently this script does not make it possible to qualify the version, 'GA' is always implied
echo "Executing $DOTNET_INSTALL_SCRIPT --version $version --channel $channel --install-dir $DOTNET_INSTALL_DIR" echo "Executing $DOTNET_INSTALL_SCRIPT --version $version --channel $channel --install-dir $DOTNET_ROOT"
"$DOTNET_INSTALL_SCRIPT" \ "$DOTNET_INSTALL_SCRIPT" \
--version "$version" \ --version "$version" \
--channel "$channel" \ --channel "$channel" \
--install-dir "$DOTNET_INSTALL_DIR" --install-dir "$DOTNET_ROOT"
} }
# Installs a version of the .NET Runtime # Installs a version of the .NET Runtime
...@@ -107,12 +106,12 @@ install_runtime() { ...@@ -107,12 +106,12 @@ install_runtime() {
version="$inputVersion" version="$inputVersion"
fi fi
echo "Executing $DOTNET_INSTALL_SCRIPT --runtime $runtime --version $version --channel $channel --install-dir $DOTNET_INSTALL_DIR --no-path" echo "Executing $DOTNET_INSTALL_SCRIPT --runtime $runtime --version $version --channel $channel --install-dir $DOTNET_ROOT --no-path"
"$DOTNET_INSTALL_SCRIPT" \ "$DOTNET_INSTALL_SCRIPT" \
--runtime "$runtime" \ --runtime "$runtime" \
--version "$version" \ --version "$version" \
--channel "$channel" \ --channel "$channel" \
--install-dir "$DOTNET_INSTALL_DIR" \ --install-dir "$DOTNET_ROOT" \
--no-path --no-path
} }
......
...@@ -13,6 +13,12 @@ source dev-container-features-test-lib ...@@ -13,6 +13,12 @@ source dev-container-features-test-lib
source dotnet_env.sh source dotnet_env.sh
source dotnet_helpers.sh source dotnet_helpers.sh
check "dotnet is installed in DOTNET_ROOT and execute permission is granted" \
test -x "$DOTNET_ROOT/dotnet"
check "dotnet is symlinked correctly in /usr/bin" \
test -L /usr/bin/dotnet -a "$(readlink -f /usr/bin/dotnet)" = "$DOTNET_ROOT/dotnet"
expected=$(fetch_latest_version) expected=$(fetch_latest_version)
check "Latest .NET SDK version installed" \ check "Latest .NET SDK version installed" \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment