Unverified Commit c04ead01 authored by Nebula's avatar Nebula Committed by GitHub

Add support for including PowerShell profile (#804)

* Add support for including PowerShell profile

* Update version in devcontainer-feature.json

* Add powershellProfileURL  to options

* Update src/powershell/devcontainer-feature.json
Co-authored-by: 's avatarSamruddhi Khandale <samruddhikhandale@github.com>

* Update README.md

* Create testProfile.ps1

Added a Profile for testing

* Add powershell profile test

* Update install_modules.sh

* Undo README.md changes

* Update scenarios.json

* Delete test/powershell/testProfile.ps1

---------
Co-authored-by: 's avatarSamruddhi Khandale <samruddhikhandale@github.com>
Co-authored-by: 's avatarSamruddhi Khandale <skhandale@microsoft.com>
parent 403c8964
{ {
"id": "powershell", "id": "powershell",
"version": "1.2.0", "version": "1.3.0",
"name": "PowerShell", "name": "PowerShell",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/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.", "description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
"type": "string", "type": "string",
"default": "", "default": "",
"description": "Optional comma separated list of PowerShell modules to install." "description": "Optional comma separated list of PowerShell modules to install."
},
"powershellProfileURL ": {
"type": "string",
"default": "",
"description": "Optional (publicly accessible) URL to download PowerShell profile."
} }
}, },
"customizations": { "customizations": {
......
...@@ -14,6 +14,7 @@ rm -rf /var/lib/apt/lists/* ...@@ -14,6 +14,7 @@ rm -rf /var/lib/apt/lists/*
POWERSHELL_VERSION=${VERSION:-"latest"} POWERSHELL_VERSION=${VERSION:-"latest"}
POWERSHELL_MODULES="${MODULES}" POWERSHELL_MODULES="${MODULES}"
POWERSHELL_PROFILE_URL="${PROFILE_URL}"
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
POWERSHELL_ARCHIVE_ARCHITECTURES="amd64" POWERSHELL_ARCHIVE_ARCHITECTURES="amd64"
...@@ -162,6 +163,12 @@ if [ ${#POWERSHELL_MODULES[@]} -gt 0 ]; then ...@@ -162,6 +163,12 @@ if [ ${#POWERSHELL_MODULES[@]} -gt 0 ]; then
done done
fi fi
# If URL for powershell profile is provided, download it to '/opt/microsoft/powershell/7/profile.ps1'
if [ -n "$POWERSHELL_PROFILE_URL" ]; then
echo "Downloading PowerShell Profile from: $POWERSHELL_PROFILE_URL"
curl -sSL -o "/opt/microsoft/powershell/7/profile.ps1" "$POWERSHELL_PROFILE_URL"
fi
# Clean up # Clean up
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
......
...@@ -8,6 +8,7 @@ source dev-container-features-test-lib ...@@ -8,6 +8,7 @@ source dev-container-features-test-lib
# Extension-specific tests # Extension-specific tests
check "az.resources" pwsh -Command "(Get-Module -ListAvailable -Name Az.Resources).Version.ToString()" 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()" check "az.storage" pwsh -Command "(Get-Module -ListAvailable -Name Az.Storage).Version.ToString()"
check "profile" pwsh -Command "(Get-Variable $env:ProfileLoaded).Value"
# Report result # Report result
reportResults reportResults
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
"image": "mcr.microsoft.com/devcontainers/base:jammy", "image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": { "features": {
"powershell": { "powershell": {
"modules": "az.resources, az.storage" "modules": "az.resources, az.storage",
"powershellProfileURL": "https://raw.githubusercontent.com/codspace/powershell-profile/main/Test-Profile.ps1"
} }
} }
} }
......
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