I have a file 'releaseVersionNumber.txt' which I read during my build process; currently its read for my Mac build but I want to read it in my Windows NSIS build to reduce the number of edit locations (duplication being evil)...
So I'm trying to replace:
!define VERSION 1.2.3
with something like
FileOpen $4 "..\releaseVersionNumber.txt" r
FileRead $4 $1
FileClose $4
!define VERSION ${1}
But I get an error command FileOpen not valid outside Section or Function. Wrapping it in a function I produces command call not valid outside Section or Function so I can't seem to do this in the installer setup, only at runtime.
Is there a way to achieve what I'm after?!
All commands begining with !
are compile time commands, so they are processed at compile time, much before your program runs.
You can try declaring VERSION
as a Variable instead of a define:
Var VERSION
FileOpen $4 "..\releaseVersionNumber.txt" r
FileRead $4 $VERSION
FileClose $4
If you need VERSION
to be a define, then you can try the /file
parameter in !define.
!define /file VERSION "..\releaseVersionNumber.txt"
I like to have a version.nsh
file with just the define:
!define VERSION "2013-03-25:16:23:50"
And then, I include it:
!include /NONFATAL version.nsh
# Default value in case no version.nsh is present
!ifndef VERSION
!define /date VERSION "%Y-%m-%d %H:%M:%S"
!endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With