Archive: nsis installer with dev/qa/prod config settings


nsis installer with dev/qa/prod config settings
Hi,
After successful install, I would like to launch an url but I don't want to hard code the production url inside the installer.
Is there a way we can have a external config file where nsis can read during the installation?
Thanks
Suresh M


Yes of course. Use ReadINIStr, ConfigRead or FileRead etc

Stu


Thanks for your reply. So, I have to deploy the config file as part of the installer and read the settings on successful installation, right?
I also launch an url on end of uninstall or install failed, in this case we may not have the config file. How to handle this?
thanks again
Suresh M


I also launch an url on end of uninstall or install failed, in this case we may not have the config file. How to handle this?
Use functions un.onUninstSuccess and .onUserAbort/.onInstFailed respectively .

Thanks Red Wine. That was not my question, I already do that. My question is if config file gets removed during uninstall or failed to install, how can I use ConfigRead?


The url could be stored in a definition I guess, I can't see the point of reading the url from an external file.
Anyway, simply exclude the config.cfg or whatever is the name from the uninstall list.


ok may be I didnt explain it well. Let me try again.
I create an installer with the url defined in the installer script, say http://qa.server.com.
QA team tests the installer and wants to deploy to production. Instead of creating the installer again with the production url "http://prod.server.com", we want to release the installer tested in qa (thats what we should do, right)
Thats why I want to externalize the config settings out of the installer, so we can deploy in various stages (qa, staging, production) etc.,
I am not sure I understand config.cfg, if you could send me any documentation, I would appreciate it.
thanks a lot


Config.cfg is just a random name for the external configuration file.
So, you could also copy it into $PLUGINSDIR as first action of the installer/uninstaller and read the values from there.


Well, you can either have the URL hardcoded in your installer or you can load it from an external file at runtime. In the latter case your installer will depend on the external file. So it will fail if the external file was deleted, moved, renamed or never installed. The only way to overcome this dependency (and of course the preferred way) is having the URL hardcoded in the installer itself. So the best way is having the URL implemented as a define in your installer script and passing it via commandline to the MakeNSIS compiler. After your QA team has verified your installer, you re-compile that installer with the 100% identical install script. So they won't have to re-validate it. You only change the URL passed to the compiler via commandline...

!ifndef MY_URL
!error "URL not specified, aborting compilation!"
!endif

...

Section MySection
ExecShell "open" "${MY_URL}"
SectionEnd

Thanks guys.
Lord_Mulder,
It makes sense to have url encoded in the installer. I do agree with you about the external file dependency. I will implement the recompiling command line options.


Pass it via command-line like so:

makensis /DMY_URL="http://..." script.nsi

Stu


Thanks Afrow.