Fix extension build.ps1 scripts to fail on any error#5739
Merged
Conversation
Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update extension
Fix extension build.ps1 scripts to fail on any error
Sep 17, 2025
build.ps1 to fail on any errorbuild.ps1 scripts to fail on any error
JeffreyCA
approved these changes
Sep 17, 2025
weikanglim
approved these changes
Sep 17, 2025
rajeshkamal5050
approved these changes
Sep 17, 2025
wbreza
approved these changes
Sep 17, 2025
Contributor
|
/check-enforcer override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PowerShell build scripts for azd extensions were not properly failing when encountering errors, causing
azd x buildto report success even when builds failed due to missing dependencies or other issues.The problem occurred because PowerShell scripts use
$ErrorActionPreference = 'Continue'by default, which allows execution to continue after errors. Additionally, some critical setup commands likegit rev-parse HEADlacked proper error checking.This resulted in scenarios where:
go buildfails → script continues → exits with code 0 (success)Changes made:
Added
$ErrorActionPreference = 'Stop'at the beginning of all 7 extension build.ps1 scripts to ensure any error stops execution immediatelyAdded explicit error checking for
git rev-parse HEADcommands to catch git failures earlyPreserved existing error handling for build commands (go build, dotnet publish, etc.) that was already in place
Files updated:
cli/azd/extensions/microsoft.azd.ai.builder/build.ps1cli/azd/extensions/microsoft.azd.extensions/build.ps1cli/azd/extensions/microsoft.azd.demo/build.ps1cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/build.ps1cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/python/build.ps1cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/javascript/build.ps1cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/dotnet/build.ps1Now when any error occurs during extension building, the PowerShell scripts will properly exit with code 1, allowing
azd x buildto correctly detect and report the failure to users.Fixes #5738.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.