Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/powershell/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "powershell",
"version": "1.5.1",
"version": "1.6.0",
"name": "PowerShell",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell",
"description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
Expand All @@ -9,18 +9,18 @@
"type": "string",
"proposals": [
"latest",
"lts",
"none",
"7.4",
"7.3",
"7.2"
"7.5",
"7.4"
],
"default": "latest",
"description": "Select or enter a version of PowerShell."
},
"modules": {
"type": "string",
"default": "",
"description": "Optional comma separated list of PowerShell modules to install. If you need to install a specific version of a module, use '==' to specify the version (e.g. 'az.resources==2.5.0')"
"description": "Optional comma separated list of PowerShell modules to install. If you need to install a specific version of a module, use '==' to specify the version (e.g. 'az.resources==2.5.0')."
},
"powershellProfileURL": {
"type": "string",
Expand All @@ -37,7 +37,7 @@
"settings": {
"github.copilot.chat.codeGeneration.instructions": [
{
"text": "This dev container includes PowerShell along with needed dependencies pre-installed and available on the `PATH`, along with the PowerShell extension."
Comment thread
Kaniska244 marked this conversation as resolved.
"text": "This dev container includes PowerShell along with needed dependencies pre-installed and available on the `PATH`, along with the PowerShell extension.."
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions src/powershell/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,10 @@ install_using_github() {
if ! type git > /dev/null 2>&1; then
check_packages git
fi

if [ "${architecture}" = "amd64" ]; then
if [ "${architecture}" = "amd64" ] || [ "${architecture}" = "x86_64" ]; then
architecture="x64"
elif [ "${architecture}" = "aarch64" ]; then
architecture="arm64"
fi
pwsh_url="https://github.com/PowerShell/PowerShell"
find_version_from_git_tags POWERSHELL_VERSION $pwsh_url
Expand Down
4 changes: 3 additions & 1 deletion test/powershell/install_powershell_fallback_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ install_pwsh() {

install_using_github() {
mode=$1
if [ "${architecture}" = "amd64" ]; then
if [ "${architecture}" = "amd64" ] || [ "${architecture}" = "x86_64" ]; then
architecture="x64"
elif [ "${architecture}" = "aarch64" ]; then
architecture="arm64"
fi
pwsh_url="https://github.com/PowerShell/PowerShell"
POWERSHELL_VERSION="7.4.xyz"
Expand Down
15 changes: 15 additions & 0 deletions test/powershell/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"image": "mcr.microsoft.com/devcontainers/base:noble",
"features": {
"powershell": {
"version": "lts",
"modules": "az.resources, az.storage",
"powershellProfileURL": "https://raw.githubusercontent.com/codspace/powershell-profile/main/Test-Profile.ps1"
}
Expand Down Expand Up @@ -31,6 +32,20 @@
"powershell": {}
}
},
"validate_powershell_installation_spec": {
"image": "mcr.microsoft.com/devcontainers/base:noble",
"features": {
"powershell": {
"version": "7.5"
}
}
},
"validate_powershell_installation_debian": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"powershell": {}
}
},
"powershell_alma_linux": {
"image": "almalinux:9",
"features": {
Expand Down
20 changes: 20 additions & 0 deletions test/powershell/validate_powershell_installation_debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

# Import test library for `check` command
source dev-container-features-test-lib

# Extension-specific tests
check "pwsh file is symlink" bash -c "[ -L /usr/bin/pwsh ]"
check "pwsh symlink is registered as shell" bash -c "[ $(grep -c '/usr/bin/pwsh' /etc/shells) -eq 1 ]"
check "pwsh target is correct" bash -c "[ $(readlink /usr/bin/pwsh) = /opt/microsoft/powershell/7/pwsh ]"
check "pwsh target is registered as shell" bash -c "[ $(grep -c '/opt/microsoft/powershell/7/pwsh' /etc/shells) -eq 1 ]"
check "pwsh owner is root" bash -c "[ $(stat -c %U /opt/microsoft/powershell/7/pwsh) = root ]"
check "pwsh group is root" bash -c "[ $(stat -c %G /opt/microsoft/powershell/7/pwsh) = root ]"
check "pwsh file mode is -rwxr-xr-x" bash -c "[ $(stat -c '%A' /opt/microsoft/powershell/7/pwsh) = '-rwxr-xr-x' ]"
check "pwsh is in PATH" bash -c "command -v pwsh"

# Report result
reportResults

20 changes: 20 additions & 0 deletions test/powershell/validate_powershell_installation_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

# Import test library for `check` command
source dev-container-features-test-lib

# Extension-specific tests
check "pwsh file is symlink" bash -c "[ -L /usr/bin/pwsh ]"
check "pwsh symlink is registered as shell" bash -c "[ $(grep -c '/usr/bin/pwsh' /etc/shells) -eq 1 ]"
check "pwsh target is correct" bash -c "[ $(readlink /usr/bin/pwsh) = /opt/microsoft/powershell/7/pwsh ]"
check "pwsh target is registered as shell" bash -c "[ $(grep -c '/opt/microsoft/powershell/7/pwsh' /etc/shells) -eq 1 ]"
check "pwsh owner is root" bash -c "[ $(stat -c %U /opt/microsoft/powershell/7/pwsh) = root ]"
check "pwsh group is root" bash -c "[ $(stat -c %G /opt/microsoft/powershell/7/pwsh) = root ]"
check "pwsh file mode is -rwxr-xr-x" bash -c "[ $(stat -c '%A' /opt/microsoft/powershell/7/pwsh) = '-rwxr-xr-x' ]"
check "pwsh is in PATH" bash -c "command -v pwsh"

# Report result
reportResults