How do I build two different installers from the same script in Inno Setup? - inno-setup

I want to make a "standard" install for external use, but I also want to use the same script and tell it (with a command line param perhaps?) to include another set of files (PDB files for debugging) for our lab installations. (And make a totally different install exe)
How can I do this? Is it possible?
I don't see how to set this in the [Files] section (conditionally add files based on some value/param)
Note – this is not for allowing the user an option DURING the install. I want a build-time option to set in my hudson build or batch file.
I suppose I can just create a separate installer for the pdbs, but I'd rather just have one file to do everything.

You can simply use
#ifdef DebugVersion
File: *.pdb ...
#endif
and then call the Inno compiler like this:
iscc.exe -DDebugVersion ...
I'd also add something like this so you get different output file names:
#ifdef DebugVersion
OutputBaseFileName=mysetup-dbg
#else
OutputBaseFileName=mysetup
#endif
Note that you'll probably need the InnoSetup precompiler for this, which, for some inexplicable reason, is not part of the default InnoSetup package. The easiest way to get it is to get the "Quick Start Pack" from the InnoSetup download page.

The answer is simple: create two files for each release, but put the common stuff in a third file and #include it in the other two.
http://rickborup.blogspot.com/2006/09/inno-setup-include-directive.html

Related

Multiple output directories

Is it possible to use as an output directory not only one location?
Something like this:
[Setup]
OutputDir=C:\MyProject; C:\Installers
No, you cannot.
If you are compiling the installer as a part of a larger build process, you can clone the output files as part of that.
See also:
Run a [Code] or PowerShell script in Inno Setup compiler
One possible hack would be to execute some script in the background using preprocessor (as shown in the answer to the question above). And have the script watch for changes to the output file and copy it over to the other destination.

Add file after generating the installer executable

I would if we can add some files(text or executable) to a NSIS installer with a tool(or not) after the package is done.
Thank you for your help
You cannot really append extra files after the compiler has finished. You can however append a small text string if you need to embed some sort of id/hash/serial number. This data can be read with the ReadCustomerData function from the NSIS wiki.
You can compile installers on Windows and POSIX based systems so you can build installers anywhere if you absolutely need to add a file that does not exist on your system...

How to create multiple setup applications with one .iss config?

Is it possible for one .iss file to produce different setup exes at the same time? maybe with multiple [Setup] sections?
It is not possible to create more than one output setup exe at the same time, but it is possible to create more than one from a single script.
The key is to use ISPP's #define and #ifdef or #if directives to designate parts of your script which are only compiled if specific variables are defined or given a particular value. You can then use a batch script to invoke iscc with the /dVAR or /dVAR="VALUE" parameters (which are the equivalent of a #define) to select different conditions for each compile.
This is only really useful if the scripts are largely the same, however (eg. if you want to make separate installers for different "editions" of an application, instead of including all files for the largest edition and deciding at runtime which to install). If your scripts are completely different from each other, then you should just create separate scripts and compile them from a batch file or an automated build script.
Test result:
By running a simple test... No, this is not possible. At first you can introduce sections on several places in a script. Consider you can do the following in your script:
[Setup]
AppName=My Program 1
AppVersion=1.5
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
[Setup]
DefaultDirName={pf}\My Program
From that you can see that compiler wouldn't recognize which one of the [Setup] sections belongs to which setup if you could write the script for more of them in one script file.
Workaround:
However, if you need to automate the build process on a basic level, you can create a batch file and run the compiler through the command line for all of your scripts. See the reference about command line compiler usage.
If you will compile several scripts with the same output directory, don't forget to specify different value of the OutputBaseFilename directive (the output exe name) for each script file.

Can configure generate .h files?

On Linux, when I execute ./configure it generates header files and also .c files (besides Makefiles), right? How can I get configure to do that?
You will probably want to create a configure.ac (but depend on the autoconf version), but read here, to give you an idea what should you create and what is auto generated. It has good covered on the autotools topic.
It's typically used to generate config header, that contains various defines (often libraries & function present or not). But this happens only if autotools were instructed to create configure doing that.
You define what goes to (and to which header exactly) in configure.ac (input file to autotools). See AC_CONFIG_HEADERS, AC_CHECK_HEADER, AC_CHECK_LIB and similar macros. See autoconf manual for details. Also read through complete tutorial jasonw linked. And see how things are done in some existing projects.

Is it possible to control which files to install from command line for INNO installer?

I would like to control a subset of files and only allow some of them to be installed if run with a command line switch for instance.
Is this possible?
For example
if (some condition)
install full set of files
else
Install other set of files
Alternatively I can just run another installer but then I have to pass the file/path location to that second installer. There is also the issue of bundling that second installer with the first one. I think that part is not that difficult though
Yes, it is even rather easy. There are several ways to do this, all of which depend on Pascal scripting.
Method 1
You can use the GetCmdTail, ParamCount, and ParamStr functions to obtain the entire or parts of the command-line.
Then you can use the Check parameter on separate files. Hence, each file will be installed if and only if the called function returns true.

Resources