Alternative shell support#5570
Conversation
This allows pwsh to try running in pwsh5 when pwsh7 is not found in windows. User can set templates to be ShellStrict and fail if pwsh7 is not found
There was a problem hiding this comment.
Pull Request Overview
This PR introduces alternative shell support for running hooks in the Azure Developer CLI, allowing azd to automatically fallback to compatible shell alternatives when the primary shell is not available. The primary use case is enabling PowerShell 5 as a fallback when PowerShell 7 is not installed on Windows systems.
- Adds
strictShellconfiguration option to disable shell alternatives and enforce exact shell requirements - Implements PowerShell 5 fallback logic for PowerShell 7 scripts on Windows platforms
- Updates JSON schema and data models to support the new
strictShellconfiguration
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| schemas/v1.0/azure.yaml.json | Adds strictShell property definition to the JSON schema for azure.yaml configuration |
| cli/azd/pkg/tools/script.go | Extends ExecOptions struct with StrictShell boolean field |
| cli/azd/pkg/tools/powershell/powershell.go | Implements alternative shell logic with PowerShell 5 fallback for Windows |
| cli/azd/pkg/tools/powershell/powershell_test.go | Adds test coverage for alternative shell execution behavior |
| cli/azd/pkg/ext/models.go | Adds StrictShell field to HookConfig struct with YAML binding |
| cli/azd/pkg/ext/hooks_runner.go | Connects hook configuration to execution options for strict shell enforcement |
wbreza
left a comment
There was a problem hiding this comment.
This would be a good item to review in our next team architecture sync.
Co-authored-by: JeffreyCA <jeffreyca16@gmail.com>
…into pwsh5-support
…into pwsh5-support
JeffreyCA
left a comment
There was a problem hiding this comment.
Looks good, there are some failing tests though
Co-authored-by: JeffreyCA <jeffreyca16@gmail.com>
Co-authored-by: JeffreyCA <jeffreyca16@gmail.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Adding alternative shells support for running hooks.
Within a shell implementation, there will be alternatives for trying to run the script. For example, for pwsh, azd will try to use pwsh7 first, and if it is not installed, it will try to use pwsh5 (in Windows).
This PR introduce the concept of
alternative shelland adds powershell5 as the first alternative for pwsh7.This change will benefit azd templates' experience if they are using powershell7 scripts which are 100% compatible with powershell5, as user will not see any errors or need extra steps to first install powershell7.
Note: After this change, template authors can't do anything to force a template to only work for powershell7 and fail fast if it is missing. Azd will always try powershell5 in Windows if pwsh is not installed. If there is an error running the script using powershell5, azd willd display the main error and the next suggestion below:
fix: #4560
fix: #5573