From 60d1f535b5a64866d05b1c62ea41c61bbfb15baf Mon Sep 17 00:00:00 2001 From: Kaniska Date: Fri, 6 Feb 2026 16:23:31 +0000 Subject: [PATCH 01/10] [powershell] - Add `lts` and remove deprecated versions. --- src/powershell/devcontainer-feature.json | 8 ++++---- test/powershell/scenarios.json | 9 +++++++++ .../validate_powershell_installation_spec.sh | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 test/powershell/validate_powershell_installation_spec.sh diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index f4867cc9e..981b1efe8 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -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.", @@ -9,10 +9,10 @@ "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." diff --git a/test/powershell/scenarios.json b/test/powershell/scenarios.json index 781ebaf86..538e05f16 100644 --- a/test/powershell/scenarios.json +++ b/test/powershell/scenarios.json @@ -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" } @@ -31,6 +32,14 @@ "powershell": {} } }, + "validate_powershell_installation_spec": { + "image": "mcr.microsoft.com/devcontainers/base:noble", + "features": { + "powershell": { + "version": "7.5" + } + } + }, "powershell_alma_linux": { "image": "almalinux:9", "features": { diff --git a/test/powershell/validate_powershell_installation_spec.sh b/test/powershell/validate_powershell_installation_spec.sh new file mode 100644 index 000000000..20b930d26 --- /dev/null +++ b/test/powershell/validate_powershell_installation_spec.sh @@ -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 + From 4ccaf05003b9979facb810b418d2504ed1ff54e3 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Fri, 6 Feb 2026 16:40:39 +0000 Subject: [PATCH 02/10] re-triggger test --- src/powershell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 981b1efe8..892a5a22a 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -20,7 +20,7 @@ "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", From d3ab948e6891c293fb60860b7f415ff1cac14ff8 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Mon, 9 Feb 2026 07:06:55 +0000 Subject: [PATCH 03/10] Re-trigger the test. --- src/powershell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 892a5a22a..e58f276ff 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -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." + "text": "This dev container includes PowerShell along with needed dependencies pre-installed and available on the `PATH`, along with the PowerShell extension.." } ] } From 3257ea739afb9c5f69e3b5d60b64121c83edd93e Mon Sep 17 00:00:00 2001 From: Kaniska Date: Mon, 9 Feb 2026 13:32:28 +0000 Subject: [PATCH 04/10] Support powershell installation in debian trixie(13) --- src/powershell/install.sh | 5 +++-- .../install_powershell_fallback_test.sh | 4 +++- test/powershell/scenarios.json | 6 ++++++ ...validate_powershell_installation_debian.sh | 20 +++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 test/powershell/validate_powershell_installation_debian.sh diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 3da7a231b..0a1703494 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -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 diff --git a/test/powershell/install_powershell_fallback_test.sh b/test/powershell/install_powershell_fallback_test.sh index 169863c7b..b12e39b6e 100644 --- a/test/powershell/install_powershell_fallback_test.sh +++ b/test/powershell/install_powershell_fallback_test.sh @@ -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" diff --git a/test/powershell/scenarios.json b/test/powershell/scenarios.json index 538e05f16..97662a80a 100644 --- a/test/powershell/scenarios.json +++ b/test/powershell/scenarios.json @@ -40,6 +40,12 @@ } } }, + "validate_powershell_installation_debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "powershell": {} + } + }, "powershell_alma_linux": { "image": "almalinux:9", "features": { diff --git a/test/powershell/validate_powershell_installation_debian.sh b/test/powershell/validate_powershell_installation_debian.sh new file mode 100644 index 000000000..20b930d26 --- /dev/null +++ b/test/powershell/validate_powershell_installation_debian.sh @@ -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 + From e6990fc0b0bbc1d50a7ea9d06135c68fb3127be9 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Mon, 9 Feb 2026 16:47:09 +0000 Subject: [PATCH 05/10] Supporting `lts`, `preview` and `stable`. --- src/powershell/devcontainer-feature.json | 4 +- src/powershell/install.sh | 98 ++++++++++++++++++- test/powershell/powershell_preview_version.sh | 14 +++ .../powershell_preview_version_debian.sh | 14 +++ test/powershell/powershell_stable_version.sh | 14 +++ .../powershell_stable_version_debian.sh | 14 +++ test/powershell/scenarios.json | 32 ++++++ 7 files changed, 184 insertions(+), 6 deletions(-) create mode 100755 test/powershell/powershell_preview_version.sh create mode 100755 test/powershell/powershell_preview_version_debian.sh create mode 100755 test/powershell/powershell_stable_version.sh create mode 100755 test/powershell/powershell_stable_version_debian.sh diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index e58f276ff..579499498 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "powershell", - "version": "1.6.0", + "version": "2.0.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.", @@ -10,6 +10,8 @@ "proposals": [ "latest", "lts", + "preview", + "stable", "none", "7.5", "7.4" diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 0a1703494..f382babf3 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -48,6 +48,26 @@ clean_cache() { rm -rf /var/cache/dnf/* fi } +# Function to resolve PowerShell version from Microsoft redirect URLs +resolve_powershell_version() { + local version_tag="$1" + local redirect_url="https://aka.ms/powershell-release?tag=${version_tag}" + + # Follow the redirect and extract the version from the final URL + local resolved_url + resolved_url=$(curl -sSL -o /dev/null -w '%{url_effective}' "${redirect_url}") + + # Extract version from URL (e.g., https://github.com/PowerShell/PowerShell/releases/tag/v7.4.7 -> 7.4.7) + local resolved_version + resolved_version=$(echo "${resolved_url}" | grep -oP 'v\K[0-9]+\.[0-9]+\.[0-9]+(-\w+\.\d+)?' || echo "") + + if [ -z "${resolved_version}" ]; then + echo "Failed to resolve version for tag: ${version_tag}" >&2 + return 1 + fi + + echo "${resolved_version}" +} # Install dependencies for RHEL/CentOS/AlmaLinux (DNF-based systems) install_using_dnf() { dnf remove -y curl-minimal @@ -100,6 +120,58 @@ detect_package_manager() { fi } +# Function to find the latest preview version from git tags +find_preview_version_from_git_tags() { + local variable_name=$1 + local requested_version=${!variable_name} + local repository_url=$2 + + if [ -z "${googlegit_cmd_name}" ]; then + if type git > /dev/null 2>&1; then + git_cmd_name="git" + else + echo "Git not found. Cannot determine preview version." + return 1 + fi + fi + + # Fetch tags from remote repository + local tags + tags=$(git ls-remote --tags "${repository_url}" 2>/dev/null | grep -oP 'refs/tags/v\K[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+' | sort -V) + + if [ -z "${tags}" ]; then + echo "No preview tags found in repository." + return 1 + fi + + local version="" + + if [ "${requested_version}" = "preview" ] || [ "${requested_version}" = "latest" ]; then + # Get the latest preview version + version=$(echo "${tags}" | tail -n 1) + elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+$ ]]; then + # Partial version provided (e.g., "7.6"), find latest preview matching that major.minor + version=$(echo "${tags}" | grep "^${requested_version}\." | tail -n 1) + elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-preview$ ]]; then + # Version like "7.6.0-preview" provided, find latest preview for that version + local base_version="${requested_version%-preview}" + version=$(echo "${tags}" | grep "^${base_version}-preview\." | tail -n 1) + elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+$ ]]; then + # Exact preview version provided, verify it exists + if echo "${tags}" | grep -q "^${requested_version}$"; then + version="${requested_version}" + fi + fi + + if [ -z "${version}" ]; then + echo "Could not find matching preview version for: ${requested_version}" + return 1 + fi + + declare -g "${variable_name}=${version}" + echo "${variable_name}=${version}" +} + # Figure out correct version of a three part version number is not passed find_version_from_git_tags() { local variable_name=$1 @@ -302,7 +374,14 @@ install_using_github() { architecture="arm64" fi pwsh_url="https://github.com/PowerShell/PowerShell" - find_version_from_git_tags POWERSHELL_VERSION $pwsh_url + # Check if we need to find a preview version or stable version + if [[ "${POWERSHELL_VERSION}" == *"preview"* ]] || [ "${POWERSHELL_VERSION}" = "preview" ]; then + echo "Finding preview version..." + find_preview_version_from_git_tags POWERSHELL_VERSION "${pwsh_url}" + else + find_version_from_git_tags POWERSHELL_VERSION "${pwsh_url}" + fi + install_pwsh "${POWERSHELL_VERSION}" if grep -q "Not Found" "${powershell_filename}"; then install_prev_pwsh $pwsh_url @@ -313,7 +392,6 @@ install_using_github() { mkdir ~/powershell tar -xvf powershell-${POWERSHELL_VERSION}-linux-x64.tar.gz -C ~/powershell - powershell_archive_sha256="$(cat release.html | tr '\n' ' ' | sed 's|<[^>]*>||g' | grep -oP "${powershell_filename}\s+\K[0-9a-fA-F]{64}" || echo '')" if [ -z "${powershell_archive_sha256}" ]; then echo "(!) WARNING: Failed to retrieve SHA256 for archive. Skipping validaiton." @@ -331,6 +409,17 @@ install_using_github() { if ! type pwsh >/dev/null 2>&1; then export DEBIAN_FRONTEND=noninteractive + if [ "${POWERSHELL_VERSION}" = "lts" ] || [ "${POWERSHELL_VERSION}" = "stable" ] || [ "${POWERSHELL_VERSION}" = "preview" ]; then + echo "Resolving PowerShell '${POWERSHELL_VERSION}' version from Microsoft..." + resolved_version=$(resolve_powershell_version "${POWERSHELL_VERSION}") + if [ -n "${resolved_version}" ]; then + echo "Resolved '${POWERSHELL_VERSION}' to version: ${resolved_version}" + POWERSHELL_VERSION="${resolved_version}" + else + echo "Warning: Could not resolve '${POWERSHELL_VERSION}' version. Falling back to 'latest'." + POWERSHELL_VERSION="latest" + fi + fi # Source /etc/os-release to get OS info . /etc/os-release @@ -341,11 +430,10 @@ if ! type pwsh >/dev/null 2>&1; then POWERSHELL_ARCHIVE_ARCHITECTURES="${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}" fi - if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then + if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]]; then install_using_apt || use_github="true" - elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]]; then + elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]]; then install_using_dnf && install_powershell_dnf || use_github="true" - else use_github="true" fi diff --git a/test/powershell/powershell_preview_version.sh b/test/powershell/powershell_preview_version.sh new file mode 100755 index 000000000..7e49ded9e --- /dev/null +++ b/test/powershell/powershell_preview_version.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test preview version installation +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/powershell_preview_version_debian.sh b/test/powershell/powershell_preview_version_debian.sh new file mode 100755 index 000000000..316017cf7 --- /dev/null +++ b/test/powershell/powershell_preview_version_debian.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test preview version installation on Debian +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/powershell_stable_version.sh b/test/powershell/powershell_stable_version.sh new file mode 100755 index 000000000..b82439ff8 --- /dev/null +++ b/test/powershell/powershell_stable_version.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test stable version installation +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is stable (not preview)" bash -c "pwsh --version | grep -v 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/powershell_stable_version_debian.sh b/test/powershell/powershell_stable_version_debian.sh new file mode 100755 index 000000000..45a14c90f --- /dev/null +++ b/test/powershell/powershell_stable_version_debian.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test stable version installation on Debian +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is stable (not preview)" bash -c "pwsh --version | grep -v 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/scenarios.json b/test/powershell/scenarios.json index 97662a80a..bc8e52b0b 100644 --- a/test/powershell/scenarios.json +++ b/test/powershell/scenarios.json @@ -51,5 +51,37 @@ "features": { "powershell": {} } + }, + "powershell_stable_version": { + "image": "mcr.microsoft.com/devcontainers/base:noble", + "features": { + "powershell": { + "version": "stable" + } + } + }, + "powershell_preview_version": { + "image": "mcr.microsoft.com/devcontainers/base:noble", + "features": { + "powershell": { + "version": "preview" + } + } + }, + "powershell_stable_version_debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "powershell": { + "version": "stable" + } + } + }, + "powershell_preview_version_debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "powershell": { + "version": "preview" + } + } } } From 36541290d74736e121da7bcff0da1127c7af5e67 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Mon, 9 Feb 2026 16:55:55 +0000 Subject: [PATCH 06/10] Remove extra dot(.) --- src/powershell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 579499498..2f511b212 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -39,7 +39,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.." + "text": "This dev container includes PowerShell along with needed dependencies pre-installed and available on the `PATH`, along with the PowerShell extension." } ] } From a2081f0c39fb0ebbe4b2eed33450da4e7c7caaf8 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Tue, 10 Feb 2026 04:29:43 +0000 Subject: [PATCH 07/10] Retrigger test --- src/powershell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 2f511b212..579499498 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -39,7 +39,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." + "text": "This dev container includes PowerShell along with needed dependencies pre-installed and available on the `PATH`, along with the PowerShell extension.." } ] } From 41f9520e51edebb7fd1f10d5a73c52df40fd8831 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Tue, 10 Feb 2026 05:18:41 +0000 Subject: [PATCH 08/10] Added tests for almalinux --- src/powershell/README.md | 2 +- src/powershell/devcontainer-feature.json | 2 +- src/powershell/install.sh | 23 +++++++++++++++--- .../powershell_lts_version_almalinux.sh | 14 +++++++++++ .../powershell_preview_version_almalinux.sh | 14 +++++++++++ .../powershell_stable_version_almalinux.sh | 14 +++++++++++ test/powershell/scenarios.json | 24 +++++++++++++++++++ 7 files changed, 88 insertions(+), 5 deletions(-) create mode 100755 test/powershell/powershell_lts_version_almalinux.sh create mode 100755 test/powershell/powershell_preview_version_almalinux.sh create mode 100755 test/powershell/powershell_stable_version_almalinux.sh diff --git a/src/powershell/README.md b/src/powershell/README.md index 31199a4e1..f09ac1f02 100644 --- a/src/powershell/README.md +++ b/src/powershell/README.md @@ -7,7 +7,7 @@ Installs PowerShell along with needed dependencies. Useful for base Dockerfiles ```json "features": { - "ghcr.io/devcontainers/features/powershell:1": {} + "ghcr.io/devcontainers/features/powershell:2": {} } ``` diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 579499498..2f511b212 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -39,7 +39,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.." + "text": "This dev container includes PowerShell along with needed dependencies pre-installed and available on the `PATH`, along with the PowerShell extension." } ] } diff --git a/src/powershell/install.sh b/src/powershell/install.sh index f382babf3..7d554634e 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -231,7 +231,8 @@ apt_get_update() for package in "$@"; do if ! dnf list installed "$package" > /dev/null 2>&1; then echo "Package $package not installed. Installing using dnf..." - dnf install -y "$package" + # Use --allowerasing to handle conflicts like curl-minimal vs curl + dnf install -y --allowerasing "$package" else echo "Package $package is already installed (DNF)." fi @@ -364,7 +365,14 @@ install_pwsh() { install_using_github() { # Fall back on direct download if no apt package exists in microsoft pool - check_packages curl ca-certificates gnupg2 dirmngr libc6 libgcc1 libgssapi-krb5-2 libstdc++6 libunwind8 libuuid1 zlib1g libicu[0-9][0-9] + # Fall back on direct download if no apt package exists in microsoft pool + if command -v apt-get > /dev/null 2>&1; then + # Debian/Ubuntu dependencies + check_packages curl ca-certificates gnupg2 dirmngr libc6 libgcc1 libgssapi-krb5-2 libstdc++6 libunwind8 libuuid1 zlib1g libicu[0-9][0-9] + elif command -v dnf > /dev/null 2>&1; then + # AlmaLinux/RHEL dependencies + check_packages curl ca-certificates gnupg2 glibc libgcc krb5-libs libstdc++ libuuid zlib libicu wget tar + fi if ! type git > /dev/null 2>&1; then check_packages git fi @@ -402,7 +410,16 @@ install_using_github() { tar xf "${powershell_filename}" -C "${powershell_target_path}" chmod 755 "${powershell_target_path}/pwsh" ln -sf "${powershell_target_path}/pwsh" /usr/bin/pwsh - add-shell "/usr/bin/pwsh" + # Add pwsh to /etc/shells + if command -v add-shell > /dev/null 2>&1; then + # Debian/Ubuntu - use add-shell + add-shell "/usr/bin/pwsh" + else + # AlmaLinux/RHEL - manually add to /etc/shells - add-shell is not available in almalinux repos and manual approach is simpler than adding a dependency just for this + if ! grep -q "/usr/bin/pwsh" /etc/shells; then + echo "/usr/bin/pwsh" >> /etc/shells + fi + fi cd /tmp rm -rf /tmp/pwsh } diff --git a/test/powershell/powershell_lts_version_almalinux.sh b/test/powershell/powershell_lts_version_almalinux.sh new file mode 100755 index 000000000..a37598913 --- /dev/null +++ b/test/powershell/powershell_lts_version_almalinux.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test LTS version installation on AlmaLinux +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is LTS (not preview)" bash -c "pwsh --version | grep -v 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/powershell_preview_version_almalinux.sh b/test/powershell/powershell_preview_version_almalinux.sh new file mode 100755 index 000000000..3a8128209 --- /dev/null +++ b/test/powershell/powershell_preview_version_almalinux.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test preview version installation on AlmaLinux +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/powershell_stable_version_almalinux.sh b/test/powershell/powershell_stable_version_almalinux.sh new file mode 100755 index 000000000..7695995f5 --- /dev/null +++ b/test/powershell/powershell_stable_version_almalinux.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test stable version installation on AlmaLinux +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is stable (not preview)" bash -c "pwsh --version | grep -v 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/scenarios.json b/test/powershell/scenarios.json index bc8e52b0b..d302f1ace 100644 --- a/test/powershell/scenarios.json +++ b/test/powershell/scenarios.json @@ -83,5 +83,29 @@ "version": "preview" } } + }, + "powershell_lts_version_almalinux": { + "image": "almalinux:9", + "features": { + "powershell": { + "version": "lts" + } + } + }, + "powershell_stable_version_almalinux": { + "image": "almalinux:9", + "features": { + "powershell": { + "version": "stable" + } + } + }, + "powershell_preview_version_almalinux": { + "image": "almalinux:9", + "features": { + "powershell": { + "version": "preview" + } + } } } From 667b2dfe7cfb65f449fa2caf5eda7ee5457f1e5d Mon Sep 17 00:00:00 2001 From: Kaniska Date: Tue, 10 Feb 2026 05:40:06 +0000 Subject: [PATCH 09/10] Added one more test --- test/powershell/install_modules.sh | 3 +++ test/powershell/powershell_lts_version_debian.sh | 14 ++++++++++++++ test/powershell/scenarios.json | 8 ++++++++ 3 files changed, 25 insertions(+) create mode 100755 test/powershell/powershell_lts_version_debian.sh diff --git a/test/powershell/install_modules.sh b/test/powershell/install_modules.sh index 1415af2c1..27872a479 100644 --- a/test/powershell/install_modules.sh +++ b/test/powershell/install_modules.sh @@ -5,6 +5,9 @@ set -e # Import test library for `check` command source dev-container-features-test-lib +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is LTS (not preview)" bash -c "pwsh --version | grep -v 'preview'" + # Extension-specific tests check "az.resources" pwsh -Command "(Get-Module -ListAvailable -Name Az.Resources).Version.ToString()" check "az.storage" pwsh -Command "(Get-Module -ListAvailable -Name Az.Storage).Version.ToString()" diff --git a/test/powershell/powershell_lts_version_debian.sh b/test/powershell/powershell_lts_version_debian.sh new file mode 100755 index 000000000..c216c478b --- /dev/null +++ b/test/powershell/powershell_lts_version_debian.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Test LTS version installation on Debian +check "pwsh is installed" bash -c "command -v pwsh" +check "pwsh version is LTS (not preview)" bash -c "pwsh --version | grep -v 'preview'" +check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'" + +# Report result +reportResults diff --git a/test/powershell/scenarios.json b/test/powershell/scenarios.json index d302f1ace..3e9b3acd3 100644 --- a/test/powershell/scenarios.json +++ b/test/powershell/scenarios.json @@ -76,6 +76,14 @@ } } }, + "powershell_lts_version_debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "powershell": { + "version": "lts" + } + } + }, "powershell_preview_version_debian": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { From 2ebb9163c3e5030f25d3798a4577700a0da018d5 Mon Sep 17 00:00:00 2001 From: Kaniska Date: Tue, 10 Feb 2026 09:19:45 +0000 Subject: [PATCH 10/10] Remove duplicate code comment --- src/powershell/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 7d554634e..c12b72b75 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -364,7 +364,6 @@ install_pwsh() { } install_using_github() { - # Fall back on direct download if no apt package exists in microsoft pool # Fall back on direct download if no apt package exists in microsoft pool if command -v apt-get > /dev/null 2>&1; then # Debian/Ubuntu dependencies