powershell 在github操作中运行ps2exe

2guxujil  于 2023-01-20  发布在  Shell
关注(0)|答案(1)|浏览(196)

我试图自动“编译”我的ps1脚本到push上的.exe文件。所以我写了yml文件来安装ps2 exe,然后在我的repo根目录中的脚本文件上运行它。
我从演示中取出PSScriptAnalyzer并对其进行了修改。

name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
  Run-PSScriptAnalyzer-on-Windows:
    name: Run PSScriptAnalyzer on Windows
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install PSScriptAnalyzer module
        shell: pwsh
        run: |
          Set-PSRepository PSGallery -InstallationPolicy Trusted
          Install-Module ps2exe
      - name: Get list of rules
        shell: pwsh
        run: |
          . ps2exe script.ps1

我得到的:

Run . ps2exe script.ps1
  . ps2exe script.ps1
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
PS2EXE-GUI v0.5.0.28 by Ingo Karstein, reworked and GUI support by Markus Scholtes

& : The term 'Invoke-ps2exe' is not recognized as the name of a cmdlet, function, script file, or operable program. 
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:2
+ &'Invoke-ps2exe'  -inputFile script.ps1 -nested
+  ~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Invoke-ps2exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
Error: Process completed with exit code 1.

“Invoke-ps2 exe”是我使用的ps2 exe命令调用的别名,它能找到别名说明模块安装成功,但是找不到,说:无法识别为cmdlet、函数、脚本文件或可操作程序的名称。
有人能告诉我我做错了什么吗?
谢谢

yr9zkbsy

yr9zkbsy1#

Ps2exe只在ps桌面上运行,而不是在ps核心上。

shell: pwsh

表示powershell内核。应替换为:

shell: powershell

来源:https://github.com/MScholtes/PS2EXE/issues/82

相关问题