【问题标题】:NSIS Installer runs PS1 script. That script tries to install NuGet, but installs it in x86 Program files?NSIS 安装程序运行 PS1 脚本。该脚本尝试安装 NuGet,但将其安装在 x86 程序文件中?
【发布时间】:2020-01-07 21:04:09
【问题描述】:

我有一个 NSIS 安装程序,它运行一个 ps1 文件来安装一堆东西并设置网络配置。

当它运行脚本时,它将 NuGet 安装到 ProgramFilesx86 中,由于某种原因,当我调用“Install-Module xNetworking”时它找不到它,但如果它安装在 ProgramFiles 目录中,它就可以正常工作。

我在 nsi 文件中有 SetRegView 64 选项。

为什么 NuGet 安装在 32 位目录而不是 64 位目录中?我缺少一个选项吗?

安装nuget的命令就是“Install-PackageProvider NuGet -force”

【问题讨论】:

  • 所以我发现 NSIS 是一个 32 位进程,它解释了我的问题,仍然找不到解决方法。

标签: powershell nuget nsis


【解决方案1】:

File System Redirector 会将 32 位应用程序重定向到 64 位 Windows 上的 32 位 Program Files 目录。

!include x64.nsh
RequestExecutionLevel Admin

Section
StrCpy $InstDir $ProgramFiles32
${If} ${RunningX64}
StrCpy $InstDir $ProgramFiles64
${EndIf}
${DisableX64FSRedirection}
SetOutPath $InstDir
File NativeThing.ps1
${EnableX64FSRedirection}
SectionEnd

如果您从安装程序启动 powershell,您可能还需要 make sure you are using 64-bit powershell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    • 2011-01-06
    • 1970-01-01
    • 2015-06-05
    • 2012-12-12
    • 1970-01-01
    相关资源
    最近更新 更多