为什么 VIProductVersion 参数会覆盖 ProductVersion 键的值?

发布于 2024-11-26 16:24:09 字数 726 浏览 0 评论 0原文

nsi 脚本中的代码片段:

VIProductVersion 1.2.0.0   
VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion 1.1.0.0

我想将 FileVersion 设置为 1.1.0.0,但在文件属性中它设置为 1.2.0.0。我还注意到,单独执行的 VIProductVersion 添加了 FileVersion 键并设置其值。

文档显示 VIProductVersion 添加了产品版本但我看到的是 FileVersion 实际上已添加。这是 NSIS 的错误吗?如果 VIAddVersionKey FileVersion 设置的值被 VIProductVersion 设置的值覆盖,那么它的用途是什么?

VIAddVersionKey 需要 VIProductVersion 调用,否则脚本无法编译。

我正在使用的版本:EclipseNSIS 0.9.8; MakeNSIS 2.46。操作系统:Windows 7。

Code snippet from the nsi script:

VIProductVersion 1.2.0.0   
VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion 1.1.0.0

I want to set FileVersion to 1.1.0.0 but in file properties it is set to 1.2.0.0. I also noticed that VIProductVersion executed on its own adds FileVersion key and sets its value.

Documentation says that VIProductVersion adds the Product Version but what I see is that FileVersion is actually added. Is this the bug in NSIS? What is the purpose of VIAddVersionKey FileVersion if value it sets is overriden with one set by VIProductVersion?

VIAddVersionKey requires VIProductVersion call, script does not compile otherwise.

Versions I am using: EclipseNSIS 0.9.8; MakeNSIS 2.46. OS: Windows 7.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一曲爱恨情仇 2024-12-03 16:24:09

版本信息资源存储在两部分中:

某些应用程序使用 FileVersion 字符串,如果该字符串不存在,则回退到 VS_FIXEDFILEINFO::dwFileVersion,其他应用程序仅使用 VS_FIXEDFILEINFO::dwFileVersion 等。

VIProductVersion "1.2.3.4" 将生成一个版本标头,该标头看起来

1 VERSIONINFO
FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
FILEOS 0x4
FILETYPE 0x1

这通常就足够了,但它不会让你设置 PRODUCTVERSION != FILEVERSION。

我认为这是 NSIS 中的一个错误,他们应该添加一个 VIFileVersion 命令或将 VIProductVersion 扩展为 VIProductVersion; [文件管理器]

您可以在跟踪器上添加功能请求。

同时,您可以通过在构建期间调用 资源黑客 来解决此问题使用 !packhdr


编辑:

可以在编译时使用 !packhdr、外部第 3 方工具在 2.46 中完成(我无法让 reshacker 导入 .rc 版本资源,所以我不得不首先转换为 .res)和可怕的黑客:

!macro HackyVIFileVersion reshack gorcjorg fixedfilever
;http://www.angusj.com/resourcehacker/
;http://web.archive.org/web/20090918063311/http://www.jorgon.freeserve.co.uk/Gorcjorg.zip
!searchreplace HackyVIFileVersion_id "${__TIME__}" ":" ""
!define HackyVIFileVersion_cmd "$%TEMP%\nsisVIFV${HackyVIFileVersion_id}.cmd"
!appendfile "${HackyVIFileVersion_cmd}" `@echo off&setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION$\n`
!appendfile "${HackyVIFileVersion_cmd}" `set eh=%TEMP%\exehead%~1.tmp$\n`
!appendfile "${HackyVIFileVersion_cmd}" `set rh=%~2$\n`
!appendfile "${HackyVIFileVersion_cmd}" `call "%rh%" -extract "%eh%", "%eh%1.rc", VersionInfo,1,$\n`
!appendfile "${HackyVIFileVersion_cmd}" `> "%eh%2.rc" echo.LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US $\n` ;must force lang for Gorcjorg
!appendfile "${HackyVIFileVersion_cmd}" `FOR /F "usebackq tokens=* delims=" %%A IN ("%eh%1.rc") DO ($\n`
!appendfile "${HackyVIFileVersion_cmd}" `   FOR /F "usebackq" %%B IN ('%%A') DO ($\n`
!appendfile "${HackyVIFileVersion_cmd}" `       if "%%~B"=="FILEVERSION" (>> "%eh%2.rc" echo.FILEVERSION %~4) else (>> "%eh%2.rc" echo.%%A)$\n`
!appendfile "${HackyVIFileVersion_cmd}" `   )$\n`
!appendfile "${HackyVIFileVersion_cmd}" `)$\n`
!appendfile "${HackyVIFileVersion_cmd}" `call "%~3" /fo "%eh%.res" /r "%eh%2.rc"$\n`
!appendfile "${HackyVIFileVersion_cmd}" `call "%rh%" -addoverwrite "%eh%", "%eh%", "%eh%.res", versioninfo,1,$\n`
!appendfile "${HackyVIFileVersion_cmd}" `del "%eh%2.rc"&del "%eh%1.rc"&del "%eh%.res"&del "%~0"`
!packhdr "$%TEMP%\exehead${HackyVIFileVersion_id}.tmp" '"${HackyVIFileVersion_cmd}" "${HackyVIFileVersion_id}" "${reshack}" "${gorcjorg}" "${fixedfilever}"'
!undef HackyVIFileVersion_cmd
!undef HackyVIFileVersion_id 
!macroend


VIProductVersion "1.2.3.4"
VIAddVersionKey /LANG=1033 FileVersion 5.6.7.8
VIAddVersionKey /LANG=1033 ProductVersion "1.2.3.4"
VIAddVersionKey /LANG=1033 Comments "A test comment"
!insertmacro HackyVIFileVersion "C:\tools\ResHacker.exe" "C:\tools\GoRC.exe" "5,6,7,8"

......你最终得到这个版本资源:

1 VERSIONINFO
FILEVERSION 5,6,7,8
PRODUCTVERSION 1,2,3,4
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
    BLOCK "040904e4"
    {
        VALUE "Comments", "A test comment"
        VALUE "FileVersion", "5.6.7.8"
        VALUE "ProductVersion", "1.2.3.4"
    }
}

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x0409 0x04E4
}
}

The version info resource is stored in two parts:

  • VS_FIXEDFILEINFO is a fixed block with product and file versions, VIProductVersion sets this
  • Zero, one or more (multiple languages) string blocks with one or more name=value strings, VIAddVersionKey sets those.

Some applications use the FileVersion string and fall back to VS_FIXEDFILEINFO::dwFileVersion if the string is not present, other apps only use VS_FIXEDFILEINFO::dwFileVersion etc.

VIProductVersion "1.2.3.4" will generate a version header that looks like

1 VERSIONINFO
FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
FILEOS 0x4
FILETYPE 0x1

this is often enough but it will not let you set PRODUCTVERSION != FILEVERSION.

I would consider this a bug in NSIS, they should add a VIFileVersion command or extend VIProductVersion to VIProductVersion <productver> [filever].

You can add a feature request on the tracker.

In the mean time you might be able to work around this by calling resource hacker during the build with !packhdr


Edit:

It can be done with 2.46 at compile time with !packhdr, external 3rd party tools (I was unable to get reshacker to import a .rc version resource so I had to convert to .res first) and horrible hacks:

!macro HackyVIFileVersion reshack gorcjorg fixedfilever
;http://www.angusj.com/resourcehacker/
;http://web.archive.org/web/20090918063311/http://www.jorgon.freeserve.co.uk/Gorcjorg.zip
!searchreplace HackyVIFileVersion_id "${__TIME__}" ":" ""
!define HackyVIFileVersion_cmd "$%TEMP%\nsisVIFV${HackyVIFileVersion_id}.cmd"
!appendfile "${HackyVIFileVersion_cmd}" `@echo off&setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION$\n`
!appendfile "${HackyVIFileVersion_cmd}" `set eh=%TEMP%\exehead%~1.tmp$\n`
!appendfile "${HackyVIFileVersion_cmd}" `set rh=%~2$\n`
!appendfile "${HackyVIFileVersion_cmd}" `call "%rh%" -extract "%eh%", "%eh%1.rc", VersionInfo,1,$\n`
!appendfile "${HackyVIFileVersion_cmd}" `> "%eh%2.rc" echo.LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US $\n` ;must force lang for Gorcjorg
!appendfile "${HackyVIFileVersion_cmd}" `FOR /F "usebackq tokens=* delims=" %%A IN ("%eh%1.rc") DO ($\n`
!appendfile "${HackyVIFileVersion_cmd}" `   FOR /F "usebackq" %%B IN ('%%A') DO ($\n`
!appendfile "${HackyVIFileVersion_cmd}" `       if "%%~B"=="FILEVERSION" (>> "%eh%2.rc" echo.FILEVERSION %~4) else (>> "%eh%2.rc" echo.%%A)$\n`
!appendfile "${HackyVIFileVersion_cmd}" `   )$\n`
!appendfile "${HackyVIFileVersion_cmd}" `)$\n`
!appendfile "${HackyVIFileVersion_cmd}" `call "%~3" /fo "%eh%.res" /r "%eh%2.rc"$\n`
!appendfile "${HackyVIFileVersion_cmd}" `call "%rh%" -addoverwrite "%eh%", "%eh%", "%eh%.res", versioninfo,1,$\n`
!appendfile "${HackyVIFileVersion_cmd}" `del "%eh%2.rc"&del "%eh%1.rc"&del "%eh%.res"&del "%~0"`
!packhdr "$%TEMP%\exehead${HackyVIFileVersion_id}.tmp" '"${HackyVIFileVersion_cmd}" "${HackyVIFileVersion_id}" "${reshack}" "${gorcjorg}" "${fixedfilever}"'
!undef HackyVIFileVersion_cmd
!undef HackyVIFileVersion_id 
!macroend


VIProductVersion "1.2.3.4"
VIAddVersionKey /LANG=1033 FileVersion 5.6.7.8
VIAddVersionKey /LANG=1033 ProductVersion "1.2.3.4"
VIAddVersionKey /LANG=1033 Comments "A test comment"
!insertmacro HackyVIFileVersion "C:\tools\ResHacker.exe" "C:\tools\GoRC.exe" "5,6,7,8"

...and you end up with this version resource:

1 VERSIONINFO
FILEVERSION 5,6,7,8
PRODUCTVERSION 1,2,3,4
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
    BLOCK "040904e4"
    {
        VALUE "Comments", "A test comment"
        VALUE "FileVersion", "5.6.7.8"
        VALUE "ProductVersion", "1.2.3.4"
    }
}

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x0409 0x04E4
}
}
意中人 2024-12-03 16:24:09

我想我应该提到这个错误的明显解决方法。

使用 NSIS 2.46 将 VIProductVersion 设置为您的 FileVersion,然后使用 VIAddVersionKey 设置 ProductVersion,您还需要设置文件版本以避免 NSIS 编译器警告。

VIProductVersion ${INSTALLER_VERSION}
VIAddVersionKey ProductName ${PROGRAM_NAME}
VIAddVersionKey FileVersion ${INSTALLER_VERSION}
VIAddVersionKey ProductVersion ${PROGRAM_VERSION}
...

I thought I would mention the obvious workaround for this bug.

When using NSIS 2.46 set the VIProductVersion to your FileVersion then with VIAddVersionKey set the ProductVersion, you will also need to set Fileversion to avoid a NSIS compiler warning.

VIProductVersion ${INSTALLER_VERSION}
VIAddVersionKey ProductName ${PROGRAM_NAME}
VIAddVersionKey FileVersion ${INSTALLER_VERSION}
VIAddVersionKey ProductVersion ${PROGRAM_VERSION}
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文