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

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.

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.

Compiling and executing an nsi file from another nsi file using nsis code

Suppose I have two nsi files demo.nsi (compiles to demo.exe) and setup.nsi. (compiles to setup.exe). I want to use demo.nsi inside setup.nsi in such a way that when setup.exe is executed, it compiles the demo.nsi, and then executes the demo.exe.
Just want to know if that is possible to do in nsis ?
Thanks.
Sure, it could be possible like from e.g. any batch file:
you need to call ExecWait to call makensis.exe for the compilation part
and you can call the final executable with either ExecWait or Exec depending on you need to wait for the result or not.
Beware that if you want to do that in any host, and not only the one where you prepare your setup, you will have to embed the NSIS distribution in your setup to be able to call makensis.exe and all the included files that could be necessary (included files, plugins, and other resources).

How to execute program before the uninstallation starts?

Can InnoSetup execute a program before the uninstallation starts? My program creates some registry values. I have an executable that can remove those registry values and my question is, can InnoSetup run that executable before the uninstallation starts?
See the documentation on Setup Script Sections, particularly the UninstallRun one at the bottom of the tree:
[UninstallRun]
Filename: "{app}\INIT.EXE"; Parameters: "/x"
If you need to do something more complex, you can also do it in code using the Pascal scripting functionality in InnoSetup. See UninstallCodeExample1.iss' in theInnoSetup 5\Examples` folder.

How to run an ant script from VC++

Assume a Visual C++ solution that outputs several executables. These executables are meant to be run in a certain order and with certain parameters -- and for this purpose there already is an ant build.xml script.
What would be a decent approach to integrating this ant script with VC++, such that the ant script will point against the recently output executables (.\Debug and .\Release folders) and ideally could be run directly from VC++, and dare I say with remote debugging.
I was thinking of using build post-events that populate a build.properties file with the output location of each executable, and let the ant script use this .properties file.
Any help on the matter would be great.
I'm not sure if there is a good answer for this. Perhaps you are not asking the right questions. From C++ you can launch anything, including scripts. I'm not sure what you mean by VC++ integration.
The generic answer would be:
save the output locations somewhere, doesn't matter where (file, registry, environment variables etc.)
retrieve them in the script before use
But depending on what you need, you could also try:
Output the same executables in the same folder structure. This way you can use relative paths.
Use a post-build event which copies the script in the output folder and make it use the relative path.
Instead of a script you can also try handling everything from the first EXE. Instead of an ANT script it could use a configuration file which specifies execution order and parameters.

How do I build two different installers from the same script in 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

Resources