Skip to content

Add more logging into catch block when PSScriptAnalyzer encounters a fatal error in CI #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2020

Conversation

bergmeister
Copy link
Contributor

@bergmeister bergmeister commented Jun 26, 2020

Enhancement of #236 cc @HowardWolosky

@bergmeister bergmeister changed the title Add more logging into catch block when PSScriptAnalyzer encounters a fatal error Add more logging into catch block when PSScriptAnalyzer encounters a fatal error in CI Jun 26, 2020
@HowardWolosky HowardWolosky merged commit d855e80 into microsoft:master Jun 26, 2020
@HowardWolosky
Copy link
Contributor

HowardWolosky commented Jun 28, 2020

/cc: @bergmeister
I run PSScriptAnalyzer locally, as well, and I updated my local aliases to do the same thing as this in the event of an exception. I hit the exception just now:

   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetModuleManifest(String filePath, IEnumerable`1& errorRecord)
   at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseToExportFieldsInManifest.<AnalyzeScript>d__3.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass83_1.<AnalyzeSyntaxTree>b__2()
Invoke-ScriptAnalyzer : Collection was modified; enumeration operation may not execute.
At C:\Users\Howard\OneDrive\Documents\PowerShell\Aliases.ps1:102 char:54
+ ... :analysis = Invoke-ScriptAnalyzer -Path ./ -Recurse -ErrorAction Stop ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (C:\git\PowerShe...lForGitHub.psd1:String) [Invoke-ScriptAnalyzer], CmdletInvocationException
    + FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand

@HowardWolosky
Copy link
Contributor

/cc: @bergmeister

@HowardWolosky
Copy link
Contributor

/cc: @bergmeister
Another hit of this today although the output doesn't appear to be that helpful:

2020-07-09T22:39:55.4288430Z �[91mInvoke-ScriptAnalyzer: �[0m/Users/runner/work/_temp/4d36cb14-a643-47ee-a9cc-ad64d3be6bf8.ps1:2
2020-07-09T22:39:55.4293240Z �[96mLine |
2020-07-09T22:39:55.4294420Z �[96m   2 | �[0m … lts = try { �[96mInvoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSetting�[0m …
2020-07-09T22:39:55.4295750Z �[96m     | �[91m               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-07-09T22:39:55.4296920Z �[91m�[96m     | �[91mCollection was modified; enumeration operation may not execute.
2020-07-09T22:39:55.4297840Z �[0m
2020-07-09T22:39:55.4494100Z 
2020-07-09T22:39:55.4573190Z ##[error]PowerShell exited with code '1'.
2020-07-09T22:39:55.4598950Z ##[section]Finishing: Run Static Code Analysis (PSScriptAnalyzer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants