Install PowerShell Modules (#427)
* InstallBicep * Add test for InstallBicep * Install pwsh Modules * Script rename * Add -Command to test * Check version * Install the module for all users * Adding terminating lines to scripts * Update src/powershell/install.sh Co-authored-by: Samruddhi Khandale <skhandale@microsoft.com> * Update src/powershell/install.sh Co-authored-by: Samruddhi Khandale <skhandale@microsoft.com> * Removed comments in Readme * Remove Bicep from PowerShell install * Increased version number * Update Minor version rather than patch --------- Co-authored-by: Samruddhi Khandale <skhandale@microsoft.com>
This commit is contained in:
parent
fbdc4556d5
commit
7763e0b7db
4 changed files with 43 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"id": "powershell",
|
||||
"version": "1.0.6",
|
||||
"version": "1.1.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.",
|
||||
|
@ -14,8 +14,13 @@
|
|||
],
|
||||
"default": "latest",
|
||||
"description": "Select or enter a version of PowerShell."
|
||||
}
|
||||
},
|
||||
},
|
||||
"modules": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Optional comma separated list of PowerShell modules to install."
|
||||
}
|
||||
},
|
||||
"installsAfter": [
|
||||
"ghcr.io/devcontainers/features/common-utils"
|
||||
]
|
||||
|
|
|
@ -13,6 +13,7 @@ set -e
|
|||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
POWERSHELL_VERSION=${VERSION:-"latest"}
|
||||
POWERSHELL_MODULES="${MODULES}"
|
||||
|
||||
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
|
||||
POWERSHELL_ARCHIVE_ARCHITECTURES="amd64"
|
||||
|
@ -149,6 +150,17 @@ if [ "${use_github}" = "true" ]; then
|
|||
install_using_github
|
||||
fi
|
||||
|
||||
# If PowerShell modules are requested, loop through and install
|
||||
if [ ${#POWERSHELL_MODULES[@]} -gt 0 ]; then
|
||||
echo "Installing PowerShell Modules: ${POWERSHELL_MODULES}"
|
||||
modules=(`echo ${POWERSHELL_MODULES} | tr ',' ' '`)
|
||||
for i in "${modules[@]}"
|
||||
do
|
||||
echo "Installing ${i}"
|
||||
pwsh -Command "Install-Module -Name ${i} -AllowClobber -Force -Scope AllUsers" || continue
|
||||
done
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
|
13
test/powershell/install_modules.sh
Normal file
13
test/powershell/install_modules.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Import test library for `check` command
|
||||
source dev-container-features-test-lib
|
||||
|
||||
# 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()"
|
||||
|
||||
# Report result
|
||||
reportResults
|
10
test/powershell/scenarios.json
Normal file
10
test/powershell/scenarios.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"install_modules": {
|
||||
"image": "mcr.microsoft.com/devcontainers/base:jammy",
|
||||
"features": {
|
||||
"powershell": {
|
||||
"modules": "az.resources, az.storage"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue