a1studmuffin
24th April 2002 02:40 UTC
Dynamically changing OutFile with variables?
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
rainwater
24th April 2002 04:11 UTC
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.
a1studmuffin
24th April 2002 04:38 UTC
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.
rainwater
24th April 2002 04:46 UTC
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.
a1studmuffin
24th April 2002 05:07 UTC
Yeah, that sounds like the simplest idea - thanks! :)
SmartyMan
24th April 2002 23:32 UTC
Originally posted by a1studmuffin
Ahh okay... so is what I'm trying to do impossible
You could use NSISplus & the included "copy version number" feature to do almost exactly what you wanted with a few mouseclicks.
(it not exactly the same, because NSISplus copies the version number from the version resource of your .exe to install)
a1studmuffin
25th April 2002 04:16 UTC
Ahhhh, brilliant! Just got it going! Thanks a lot, excellent app you've got there! :)