diff --git a/cli/azd/extensions/microsoft.azd.ai.builder/build.ps1 b/cli/azd/extensions/microsoft.azd.ai.builder/build.ps1 index a003f4d1029..abced22e573 100644 --- a/cli/azd/extensions/microsoft.azd.ai.builder/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.ai.builder/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -17,6 +20,10 @@ if (-not (Test-Path -Path $OUTPUT_DIR)) { # Get Git commit hash and build date $COMMIT = git rev-parse HEAD +if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Failed to get git commit hash" + exit 1 +} $BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ") # List of OS and architecture combinations diff --git a/cli/azd/extensions/microsoft.azd.demo/build.ps1 b/cli/azd/extensions/microsoft.azd.demo/build.ps1 index 99069215b12..1c2bcb6a63a 100644 --- a/cli/azd/extensions/microsoft.azd.demo/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.demo/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -17,6 +20,10 @@ if (-not (Test-Path -Path $OUTPUT_DIR)) { # Get Git commit hash and build date $COMMIT = git rev-parse HEAD +if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Failed to get git commit hash" + exit 1 +} $BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ") # List of OS and architecture combinations diff --git a/cli/azd/extensions/microsoft.azd.extensions/build.ps1 b/cli/azd/extensions/microsoft.azd.extensions/build.ps1 index a003f4d1029..abced22e573 100644 --- a/cli/azd/extensions/microsoft.azd.extensions/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.extensions/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -17,6 +20,10 @@ if (-not (Test-Path -Path $OUTPUT_DIR)) { # Get Git commit hash and build date $COMMIT = git rev-parse HEAD +if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Failed to get git commit hash" + exit 1 +} $BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ") # List of OS and architecture combinations diff --git a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/dotnet/build.ps1 b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/dotnet/build.ps1 index 16b16662e79..8af0ae35d91 100644 --- a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/dotnet/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/dotnet/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -17,6 +20,10 @@ if (-not (Test-Path -Path $OUTPUT_DIR)) { # Get Git commit hash and build date $COMMIT = git rev-parse HEAD +if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Failed to get git commit hash" + exit 1 +} $BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ") # List of OS and architecture combinations diff --git a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/build.ps1 b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/build.ps1 index 8cdd4ae9281..5ceb60a8bbc 100644 --- a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -17,6 +20,10 @@ if (-not (Test-Path -Path $OUTPUT_DIR)) { # Get Git commit hash and build date $COMMIT = git rev-parse HEAD +if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Failed to get git commit hash" + exit 1 +} $BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ") # List of OS and architecture combinations diff --git a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/javascript/build.ps1 b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/javascript/build.ps1 index 7f50f757389..50a06c1c25e 100644 --- a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/javascript/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/javascript/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path diff --git a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/python/build.ps1 b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/python/build.ps1 index b6cb3b2b7c2..111626b885a 100644 --- a/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/python/build.ps1 +++ b/cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/python/build.ps1 @@ -1,3 +1,6 @@ +# Ensure script fails on any error +$ErrorActionPreference = 'Stop' + # Get the directory of the script $EXTENSION_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -17,6 +20,10 @@ if (-not (Test-Path -Path $OUTPUT_DIR)) { # Get Git commit hash and build date $COMMIT = git rev-parse HEAD +if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Failed to get git commit hash" + exit 1 +} $BUILD_DATE = (Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ") # List of OS and architecture combinations