Hi,
First off let me say how brilliant NSIS is - it is *exactly* what I was looking for in an installation builder.
On to the question: I've got a file called version.h which contains the single line of code:
#define VERSION 0.8
I'd love to allow my NSI script to read the 0.8 and use it for the OutFile name, ie. the installer creates a file called:
asteroidsinstaller0.8.exe
Here's the beginning of my NSI script:
--- BEGIN
Section "VersionNumber"
FileOpen $R1 "version.h" r
FileSeek $R1 17 ; the 17th character is where the string 0.8 begins
FileRead $R1 $R2
FileClose $R1
SectionEnd
Name "Asteroids"
Icon "asteroid.ico"
OutFile "installer/asteroidsinstall$R2.exe"
...
--- END
This isn't working - it keeps generating the output file as the quite literal "asteroidsinstall$R2.exe". Does NSIS not support variables in the OutFile name? Or am I doing something wrong here?
Cheers
- Michael
Dynamically changing OutFile with variables?
7 posts
The outfile is determined when you compile it. Otherwise how would it create the file. A section is run when the outfile(installer) is run. There's no way to set the installer filename in a section since a section is not run until you create the installer.
Ahh okay... so is what I'm trying to do impossible? Maybe I could write a custom script to do it after the compile if that's the case.
You could write an installer that reads the version.h file, then writes a !define file that is included in your installer. Then your installer could run the makensis compiler.
Yeah, that sounds like the simplest idea - thanks! 🙂
Originally posted by a1studmuffinYou could use NSISplus & the included "copy version number" feature to do almost exactly what you wanted with a few mouseclicks.
Ahh okay... so is what I'm trying to do impossible
(it not exactly the same, because NSISplus copies the version number from the version resource of your .exe to install)
Ahhhh, brilliant! Just got it going! Thanks a lot, excellent app you've got there! 🙂