Skip to content

Commit e2ec4ea

Browse files
authored
adding powershell support to devcontainer (#17471)
## Description This PR introduces support for PowerShell in the development container and updates the [bcode.ps1](https://github.com/Azure/bicep/blob/polatengin/add-powershell-to-devcontainer/scripts/bcode.ps1#L8) script to work correctly across platforms (Windows and Linux). ## ✅ Changes Made - Added PowerShell feature to devcontainer ```json "ghcr.io/devcontainers/features/powershell:1": { "version": "latest" } ``` - Updated bcode.ps1 to avoid `-WindowStyle` error on Linux Replaced the use of `-WindowStyle` hidden with a conditional check using `$IsWindows`. The `-WindowStyle` parameter is not supported on non-Windows platforms and throws an error when used on Linux or macOS. Implementation of the start-Process can be seen in https://github.com/PowerShell/PowerShell/blob/master/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs#L1857. It throws error when `-WindowStyle` used on non-Windows platforms. ## Checklist - [x] I have read and adhere to the [contribution guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md). ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/17471)
1 parent 6367bb1 commit e2ec4ea

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"ghcr.io/devcontainers/features/node:1": {
3232
"version": "lts",
3333
"nodeGypDependencies": true
34+
},
35+
"ghcr.io/devcontainers/features/powershell:1": {
36+
"version": "latest"
3437
}
3538
}
3639
}

scripts/bcode.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55

66
$ENV:BICEP_LANGUAGE_SERVER_PATH=[System.IO.Path]::Join($PSScriptRoot,"..\src\Bicep.LangServer\bin\Debug\net8.0\Bicep.LangServer.dll")
77
$ENV:Path=[System.IO.Path]::Join($PSScriptRoot,"..\src\Bicep.Cli\bin\Debug\net8.0") + ";" + $ENV:Path
8-
& Start-Process -FilePath "code" -WindowStyle hidden -ArgumentList $args
8+
if ($IsWindows)
9+
{
10+
& Start-Process -FilePath "code" -WindowStyle hidden -ArgumentList $args
11+
}
12+
else
13+
{
14+
& Start-Process -FilePath "code" -ArgumentList $args
15+
}

0 commit comments

Comments
 (0)