Archive: Dynamic Version Information


Dynamic Version Information
Hi,

My install is rebuilt every night form a nightly build script, however ther version of the install file, set in

VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "310.0.0.154"

VIProductVersion "310.0.0.154"

Must be the same the executable about to be installed, this can be retrieved using GetDllVersionLocal, however seeing as VIAddVersionkey and VIProductVersion can not be in Sections or Functions it is hard to make dynamic.

Is it possible to retrieve the version information in .onInit and then assign it to a variable which is later assigned in VIAddVersionKey and VIProductVersion

VIProductVersion $DynamicallyDeterminedVersionNumber
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" $DynamicallyDeterminedVersionNumber


Nniol


on the top of your script execute with !system an exe that retrieves the desired info and adds them as defines to a header e.g. versions.nsh and then !include versions.nsh to your script.
e.g.
the small exe:
section
FileOpen $0 '$EXEDIR\versions.nsh
call GetDllVersionLocal
FileWrite $0 '!define File_Ver "<resulting_var_from_call>"$\r$\n'
FileClose $0
sectionend

the main script,
!system "$EXEDIR\small.exe"
!include versions.nsh
............
VIProductVersion "${File_Ver}"


edit: Red Wine beat me to it, that should teach me not to read some random blog before hitting submit :D


Thaanks guys, a real life saver there

Nniol (not so Insane anymore)


This macro does the same and a little more:
http://nsis.sourceforge.net/NfUtils_...SetVersionInfo


Originally posted by niteflyer
This macro does the same and a little more:
http://nsis.sourceforge.net/NfUtils_...SetVersionInfo
No doubt, though, I'd need an example to show me how to achieve the requested by Nniol issue. That's why my preferred way was the very simple code above :)

${nfu.SetVersionInfo} does not include /LANG= in VIAddVersionKey but you could use ${nfu.!FileVersion} to store the version in a symbol:


${nfu.!FileVersion} DynamicallyDeterminedVersionNumber "c:\myproject\myapp.exe"
VIProductVersion ${DynamicallyDeterminedVersionNumber}
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" ${DynamicallyDeterminedVersionNumber}

should do it (untested).

see http://nsis.sourceforge.net/NfUtils_....21FileVersion

If you dont need /LANG in VIAddVersionKey then you might want to use


${nfu.SetVersionInfo} "My Installer" "c:\myproject\myapp.exe" "My Company" "My Copyright 2007" "No Comments"