Nullsoft 安装程序 NSIS 未在欢迎页面上显示图像。甚至不是默认的

Nullsoft Installer NSIS not showing an image on the welcome page. Not even the default one

我正在尝试使用 MUI2 编写 NSIS 脚本,但出于某种原因它拒绝在欢迎页面上显示图像。我已按照 NSIS wiki 和手册中的说明尝试使用 MUI_WELCOMEFINISHPAGE_BITMAP。我已经使用 ${NSISDIR} 来引用包含的位图。我尝试使用包含的位图的完整路径。我尝试在我的安装文件目录中使用位图路径。

无论我做什么,我最终都会得到一个只有标题和文字但没有图像的欢迎页面。构建过程不会给出有关欢迎位图的警告或错误。安装程序会正确安装所有内容。欢迎页面上没有图片,我不知道为什么。

这是我第一次尝试使用 NSIS,所以我可能遗漏了什么。我的 .nsi 文件中包含页面定义的部分如下。任何帮助将不胜感激。

!include MUI2.nsh

# Install Warcraft II BattleNet Edition and dependencies.
Name "Warcraft II Windows 10 Setup"
Outfile "Warcraft Win10 Setup.exe"
InstallDir "C:\ISO"
# !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!define MUI_WELCOMEPAGE_TITLE "Warcraft II for Windows 10"
!define MUI_WELCOMEPAGE_TEXT "Ready to work!$\r$\n$\r$\nWith just a few simple steps, our peons will have you ready to play Warcraft II on Windows 10."
!insertmacro MUI_PAGE_WELCOME
!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose a location to store the Warcraft II CD-ROM (ISO) image."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "ISO Image Folder"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TEXT "Work complete!"
!insertmacro MUI_PAGE_FINISH

我找到了解决方案并发布给遇到同样问题的其他人。

简而言之,答案是:!insertmacro MUI_LANGUAGE "English"

显然,必须指定一种语言才能显示位图。完全有道理,是吧?是的,弗吉尼亚,那是讽刺。

我通过从下面的网站中获取示例并注释行来解决这个问题,直到我重现了欢迎页面上缺少位图图像的问题。

https://nsis.sourceforge.io/Examples/Modern%20UI/WelcomeFinish.nsi

工作代码如下所示:

!include MUI2.nsh

# Install Warcraft II BattleNet Edition and dependencies.
Name "Warcraft II Windows 10 Setup"
Outfile "Warcraft Win10 Setup.exe"
InstallDir "C:\ISO"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!define MUI_WELCOMEPAGE_TITLE "Warcraft II for Windows 10"
!define MUI_WELCOMEPAGE_TEXT "Ready to work!$\r$\n$\r$\nWith just a few simple steps, our peons will have you ready to play Warcraft II on Windows 10."
!insertmacro MUI_PAGE_WELCOME
!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose a location to store the Warcraft II CD-ROM (ISO) image."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "ISO Image Folder"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TEXT "Work complete!"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

还要确保 bmp 确实是 24 位的。否则不会渲染。