Skip to content

Commit f7cc77b

Browse files
authored
Use /etc/profile.d to set PATH for dotnet tools (#1492)
1 parent 31f99a0 commit f7cc77b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/dotnet/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "dotnet",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"name": "Dotnet CLI",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet",
66
"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.",
@@ -45,7 +45,7 @@
4545
},
4646
"containerEnv": {
4747
"DOTNET_ROOT": "/usr/share/dotnet",
48-
"PATH": "$PATH:$DOTNET_ROOT:~/.dotnet/tools",
48+
"PATH": "$PATH:$DOTNET_ROOT",
4949
"DOTNET_RUNNING_IN_CONTAINER": "true",
5050
"DOTNET_USE_POLLING_FILE_WATCHER": "true"
5151
},

src/dotnet/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ if [ ! -e /usr/bin/dotnet ]; then
146146
ln --symbolic "$DOTNET_ROOT/dotnet" /usr/bin/dotnet
147147
fi
148148

149+
# Add .NET Core SDK tools to PATH for bash and zsh users
150+
# This is where 'dotnet tool install --global <tool>' installs tools to
151+
# Use single-quoted EOF to defer $PATH expansion until sourcing the file
152+
cat << 'EOF' >> /etc/profile.d/dotnet.sh
153+
export PATH="$PATH:$HOME/.dotnet/tools"
154+
EOF
155+
149156
# Clean up
150157
rm -rf /var/lib/apt/lists/*
151158
rm -rf scripts

0 commit comments

Comments
 (0)