简体   繁体   English

在 github 动作中运行 ps2exe

[英]running ps2exe in github actions

I am trying to automatically "compile" my ps1 script to.exe file on push.我正在尝试在推送时自动将我的 ps1 脚本“编译”为 .exe 文件。 So I wrote the yml file to install ps2exe then run it on the script file that is in root of my repo.所以我编写了 yml 文件来安装 ps2exe,然后在我的 repo 根目录中的脚本文件上运行它。

I took the PSScriptAnalyzer from the demo and modified it.我从演示中取出 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

What I get:我得到什么:

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-ps2exe" is an alias called by ps2exe command that I used. “Invoke-ps2exe”是我用的ps2exe命令调用的别名。 The fact it is able to find the alias means that the module was installed successfully, yet it fails to find it and says: "is not recognized as the name of a cmdlet, function, script file, or operable program. "它能够找到别名的事实意味着模块已成功安装,但找不到它并说:“未被识别为 cmdlet、function、脚本文件或可运行程序的名称。”

Can someone please tell me what I am doing wrong here?有人可以告诉我我在这里做错了什么吗?

Thanks谢谢

Ps2exe runs only on ps desktop, not on ps core. ps2exe 只能在 ps 桌面上运行,不能在 ps core 上运行。

shell: pwsh

Means powershell core.表示powershell核心。 should be replaced with:应替换为:

shell: powershell

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM