user206904
user206904

Reputation: 550

running ps2exe in github actions

I am trying to automatically "compile" my ps1 script to .exe file on push. So I wrote the yml file to install ps2exe then run it on the script file that is in root of my repo.

I took the PSScriptAnalyzer from the demo and modified it.

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. 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. "

Can someone please tell me what I am doing wrong here?

Thanks

Upvotes: 2

Views: 3845

Answers (1)

user206904
user206904

Reputation: 550

Ps2exe runs only on ps desktop, not on ps core.

shell: pwsh

Means powershell core. should be replaced with:

shell: powershell

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

Upvotes: 5

Related Questions