Skip to content

Commit cd9dc77

Browse files
Copilotanupriya13
andcommitted
Use try-catch to suppress ASA version check STDERR error
Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
1 parent 8f2c96e commit cd9dc77

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

.ado/jobs/attack-surface-analyzer.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ jobs:
6464
# Refresh environment PATH to include .NET global tools
6565
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("PATH", "User")
6666
67-
# Verify installation by capturing output (suppress error action as asa writes to stderr)
68-
$ErrorActionPreference = 'Continue'
69-
$asaOutput = & asa --version 2>&1 | Out-String
70-
$ErrorActionPreference = 'Stop'
67+
# Verify installation by capturing output (asa writes to stderr which PowerShell treats as error)
68+
# Use try-catch to suppress the error and capture output
69+
try {
70+
$asaOutput = & asa --version 2>&1 | Out-String
71+
} catch {
72+
# Capture the error message which contains the version info
73+
$asaOutput = $_.Exception.Message
74+
}
7175
7276
Write-Host "ASA Version output: $asaOutput"
7377

0 commit comments

Comments
 (0)