Skip to content

Commit 619cd6a

Browse files
committed
Add DevContainer configuration and post-create script
This commit introduces a new DevContainer configuration file and a post-create PowerShell script. The configuration sets up a PowerShell development environment with essential features and extensions. The post-create script automates the installation of required PowerShell modules, ensuring a smooth setup process for developers. Thank you!
1 parent 81b97b8 commit 619cd6a

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "PowerShell Dev",
3+
"features": {
4+
"ghcr.io/devcontainers/features/powershell:1": {},
5+
"ghcr.io/devcontainers/features/git:1": {}
6+
},
7+
"customizations": {
8+
"extensions": [
9+
"davidanson.vscode-markdownlint",
10+
"ms-vscode.powershell",
11+
"streetsidesoftware.code-spell-checker",
12+
"redhat.vscode-yaml"
13+
]
14+
},
15+
"postCreateCommand": "pwsh .devcontainer/post-create.ps1"
16+
}

.devcontainer/post-create.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# post-create.ps1
2+
3+
Write-Host "Running DevContainer post-create setup..."
4+
5+
# Ensure scripts can run
6+
Set-ExecutionPolicy RemoteSigned -Scope Process -Force
7+
8+
# Install/update PSResourceGet side-by-side
9+
Write-Host "Installing PSResourceGet..."
10+
Install-Module Microsoft.PowerShell.PSResourceGet -Force -AllowClobber
11+
12+
# Install common modules used in this environment
13+
$requiredModules = @(
14+
"Pester",
15+
"Az.Accounts"
16+
)
17+
18+
Write-Host "Installing required modules..."
19+
foreach ($module in $requiredModules) {
20+
Install-Module $module -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber
21+
}
22+
23+
# Validate installation
24+
foreach ($module in $requiredModules) {
25+
if (-not (Get-Module -ListAvailable -Name $module)) {
26+
Write-Warning "Module [$module] did NOT install successfully!"
27+
}
28+
}
29+
30+
# Display installed versions for debugging
31+
Write-Host "Installed module versions:"
32+
33+
Get-Module -ListAvailable |
34+
Where-Object { $_.Name -in $requiredModules + "Microsoft.PowerShell.PSResourceGet" } |
35+
Sort-Object Name, Version |
36+
Format-Table Name, Version, ModuleBase

0 commit comments

Comments
 (0)