通过 NSIS 和 Powershell 脚本运行 MSYS2 进程

问题描述

所以我正在尝试构建一个 NSIS 安装程序,我需要在其中嵌入多个 PowerShell 脚本来在 MSYS2 终端中启动进程

我的一个 PowerShell 脚本的结构如下:

# 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

此处描述了语法: Invoke MSYS2 Shell from Command Prompt or PowerShell

我正在编写的用于访问 PowerShell 脚本的 NSIS 部分是

# 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

我只是想知道我在尝试使用已经编写好的 PowerShell 脚本时可能做错了什么。 NSIS 文档指出我应该将其放入 .nsh 文件中。

https://nsis.sourceforge.io/PowerShell_support

虽然我可能会误解这一点,因为我是 NSIS 的新手,欢迎纠正。

此外,我试图只链接我正确编写的 PowerShell 脚本,以便它们在 MSYS2 的安装程序完成时触发,这样用户的 MSYS2 终端中的内容就会更新,并且他们拥有运行所需的所有依赖项Cmdstan。

这是此处为 Cmdstan 提供的更大安装过程的一部分。 https://github.com/bparbhu/CmdStan-Windows10-Installer

我目前有一个通过 linux 执行此操作的安装程序: https://github.com/bparbhu/CmdStan-Linux-Installer

因此,使用 NSIS 的目标是为 Windows 用户创建一个更简单的安装过程。

我总体上想做的是安装一些只能通过 MSYS2 终端安装的东西,但我必须通过 PowerShell 作为代理来启动 MSYS2。

我不确定如何编写 PowerShell 宏来引用启动 msys2 终端代码的命令。非常感谢任何帮助或反馈。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)