From d855e80ae3fa78a5f183cfb2f319616239175669 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Fri, 26 Jun 2020 17:01:34 +0100 Subject: [PATCH] Add more logging into catch block when PSScriptAnalyzer encounters a fatal error (#246) Enhancing #236 --- build/pipelines/templates/run-staticAnalysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index 5a3a14fa..5325a767 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -9,7 +9,7 @@ steps: displayName: 'Install PSScriptAnalyzer' - powershell: | - $results = try { Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -Path ./ –Recurse -ErrorAction Stop } catch { $_.Exception.StackTrace; throw } + $results = try { Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -Path ./ –Recurse -ErrorAction Stop } catch { 'Unexpected Error'; $_.Exception.StackTrace; if ($IsCoreCLR) { Get-Error }; throw } $results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" } $null = New-Item -Path ..\ -Name ScriptAnalyzer -ItemType Directory -Force