PowerShell / PowerShell/PSScriptAnalyzer

On github actions ubuntu-latest analysis fails with "The term 'Get-Command' is not recognized as a name of a cmdlet"

未关闭
#2,205 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
2.2k
派生
414
平均合并
13 小时 1 分钟
30 天内合并 PR
2

描述

I can't exactly pinpoint what causes this. When I run the pwoershell script analyzet 1.25 on Ubuntu-latest github runners against a powershell 7 project, the analyzer fails to complete its analysis and throws:

Invoke-ScriptAnalyzer: /home/runner/work/_temp/e8c5014b-7f61-4956-b6d1-75953a6d07f6.ps1:7
Line |
   7 |  $results = Invoke-ScriptAnalyzer -Path './' -Recurse -Settings 'PSScr …
     |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The term 'Get-Command' is not recognized as a name of a cmdlet,
     | function, script file, or executable program. Check the spelling of the
     | name, or if a path was included, verify that the path is correct and try
     | again.

Reverting to 1.24 does not exhibit the issue.

Failing workflow run 1.25:
https://github.com/jessehouwing/actions-semver-checker/actions/runs/32254079386/job/96071605798

Working workflow run 1.24:
https://github.com/jessehouwing/actions-semver-checker/actions/runs/32257267058

No changes other than changing the pinned version:
https://github.com/jessehouwing/actions-semver-checker/pull/454

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先比较使用 PSScriptAnalyzer 1.25 的已链接失败 Ubuntu-latest workflow 运行与使用 1.24 的正常运行;报告称唯一的变化是固定的版本。针对一个 PowerShell 7 项目复现该分析,并确定 1.25 无法解析 Get-Command 的原因。在不回退到 1.24 的情况下,如果 1.25 的分析在同一 workflow 上成功完成,则视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
github-actions, powershell, ubuntu
领域
ci-cd
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
需要澄清
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。