Version Info manipulations on compile-time: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated by user: Lion (talk, contrib).)
m (Adding new author and category links.)
Line 1: Line 1:
{|align=right
{{PageAuthor|Lion}}
|<small>Author: [[{{ns:2}}:Lion|Lion]] ([[{{ns:3}}:Lion|talk]], [[{{ns:-1}}:Contributions/Lion|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==


Line 73: Line 71:
Lion
Lion


[[{{ns:14}}:Code Examples]]
[[Category:Code Examples]]

Revision as of 14:05, 24 June 2005

Author: Lion (talk, contrib)


Description

Recently, I was faced with the problem of automating my scripts on compile-time. I first started with the VersionInfo automation.

Examples

Before the change

This is how it WAS before (I had to change version variables manually before each compile):

;...
!define _VERSION "1.2.3.4"
;...
;from {NSISDIR}\Examples\VersionInfo.nsi
VIProductVersion "${_VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${_PRODUCT}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "..."
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${_VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "InternalName" "FileSetup.exe"
;...

After the change

And this is how it is NOW:

!define _RESHACKER "C:\WinApps\NSIS2\ResHacker\ResHacker.exe"
 
Var _VERSION
 
Function InitVersion
  !execute '"${_RESHACKER}" -extract ${_SRCDIR}\File.exe, FileVersionInfo.rc, versioninfo,1,'
 
  Push 'VALUE "FileVersion", "'
  Push '"'
  Push 'C:\WinApps\NSIS2\_Production\FileVersionInfo.rc'
  Call GetBetween
  Pop "$_VERSION"
FunctionEnd
 
Function .onInit
  ;...
  call InitVersion
  ;...
FunctionEnd
 
;...
  !execute '"${_RESHACKER}" -extract ${_SRCDIR}\File.exe, FileVersionInfo.res, versioninfo,1,'
  !packhdr tmp.dat '"${_RESHACKER}" -addoverwrite tmp.dat, tmp.dat, FileVersionInfo.res, versioninfo,1,'
  !echo "VersionInfo added"
;...

In the first case, ResHacker is used to extract decompiled VersionInfo resource from .exe to a text .rc file, the I have to parse it to get version in a string "x.x.x.x" form. Personaly, I'm using it e.g. in the installer's window caption (Caption "${_PRODUCT} v${_VERSION} Setup").

And the second case where I need ResHacker again is just duplicating the VersionInfo resource from my File.exe to FileSetup.exe.

This was inspired by these articles (listed in order of occurrence on my display :))

About the Author

I'm a newbie to NSIS's depths so please do not blame me out of hand if you found an error or smthg else not-good here.

Let the NSIS be with you!

Lion