0

So I'm trying to build an NSIS installer where I need to embed multiple PowerShell scripts that launch processes in an MSYS2 terminal.

One of my PowerShell script is structured like this:

# This is the script that updates MSYS2 for the user
bash -1 -c "pacman -Syuu --noconfirm"
bash -1 -c "pacman -Sy mingw-w64-x86_64-make --noconfirm"
bash -1 -c "pacman -Syu gcc --noconfirm"
!include psexec.nsh

The syntax is described here: Invoke MSYS2 Shell from Command Prompt or PowerShell

The NSIS section I'm writing to access the PowerShell script is

# start prerequisites section

Section -Prerequisites "Install Prerequisites needed"
    SetOutPath $INSTDIR\\Prereqresites
        
    MessageBox MB_YESNO "Install the latest version of MSYS2?" /SD IDYES IDNO endmsys2Setup
        File "Prereqresites\msys2-x86_64-20201109.exe"
        ExecWait "$INSTDIR\Prereqresites\msys2-x86_64-20201109.exe"
        ExecWait "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File psexec.nsh\msys2_setup.ps1 -FFFeatureOff"
        Goto endmsys2Setup
    endmsys2Setup:      

SectionEnd

Section close
SetAutoClose true

I just want to know what I might be doing wrong as I'm trying to use PowerShell scripts that are already written. NSIS documentation states that I should put it into a .nsh file.

https://nsis.sourceforge.io/PowerShell_support

Though I could be misinterpreting this as I'm new to NSIS and would welcome to be corrected.

Also, I'm trying to just link the PowerShell scripts I wrote correctly so that they trigger when the installer for MSYS2 finishes and that way things are updated in the MSYS2 terminal for the user and they have all the dependencies needed to run CmdStan.

This is part of a larger install process that is featured here for CmdStan. https://github.com/bparbhu/CmdStan-Windows10-Installer

I currently have an installer that does this through linux: https://github.com/bparbhu/CmdStan-Linux-Installer

So the goal for using NSIS would be to create an easier installation process for Windows users.

What I'm trying to do overall is install something that can only be installed via the MSYS2 terminal but I have to go through PowerShell as a proxy to launch MSYS2.

I'm not exactly sure how to write a PowerShell Macro to cite commands that launch msys2 terminal code. Any help or feedback is much appreciated.

  • Can you paste the compiler output with the "NSIS states that I might put it into a .nsh file" part? – Anders Apr 15 '21 at 01:39
  • Sorry for the confusion Anders I rewrote the description of my problem so I think this makes a bit more sense. – Brian Parbhu Apr 20 '21 at 04:50
  • There is a lot of stuff that does not make sense to me. `!include psexec.nsh` is a .ps1? `-File psexec.nsh\msys2_setup.ps1` is a very strange path. – Anders Apr 20 '21 at 20:54
  • Hi Anders, yeah I made a recent commit that should show how the file structure works. One of the mistakes I made was naming a folder psexc.nsh, of which contains the two PowerShell scripts. I thought by using the !include statement that the folder would be included in the import and the scripts would be recognized. I'm still not exact sure what would be the best practice for storing multiple PowerShell scripts that are meant to be used within the same installer. – Brian Parbhu Apr 21 '21 at 20:52
  • I'm open to any and all help with this at this point. Thanks again for your feedback as well I appreciate it. – Brian Parbhu Apr 21 '21 at 20:52

0 Answers0