Click here to Skip to main content
15,895,084 members
Articles / Programming Languages / SQL

Inno Setup Dependency Installer

Rate me:
Please Sign up or sign in to vote.
4.91/5 (191 votes)
7 Aug 2023CPOL2 min read 1.7M   24.9K   427   392
Download and install any dependency such as .NET, Visual C++ or SQL Server during your application's installation!
In this article, you will see installation, usage, integration, details, and dependencies of Inno Setup Dependency Installer.

Inno Setup Dependency Installer

Introduction

Inno Setup Dependency Installer can download and install any dependency such as .NET, Visual C++ or SQL Server during your application's installation. In addition, it is easy to add your own dependencies as well.

Installation and Usage

  1. Download and install Inno Setup 6.2+.
  2. Download the script from here or from the Github repository.
  3. Open the extracted ExampleSetup.iss file.
  4. Comment out dependency function calls inside InitializeSetup function to disable installing them:
    • Pascal
      Dependency_AddVC2013;   // installed in example setup
      //Dependency_AddVC2013; // commented out and not installed in example setup
  5. Modify other sections like [Setup] [Files] [Icons] as necessary.
  6. Build the setup using Inno Setup compiler.

Integration

You can also just include CodeDependencies.iss file into your setup and call the desired Dependency_Add functions (some may need defining their exe file path before the include):

Pascal
#define public Dependency_Path_NetCoreCheck "dependencies\"

#include "CodeDependencies.iss"

[Setup]
; ...

[Code]
function InitializeSetup: Boolean;
begin
  // add the dependencies you need
  Dependency_AddDotNet70;
  // ...

  Result := True;
end;

Details

You have two ways to distribute the dependency installers. By default, most dependencies will be downloaded from the official website. Another way is to pack the dependency into a single executable setup like so:

  • Include the dependency setup file by defining the source:

    Pascal
    Source: "dxwebsetup.exe"; Flags: dontcopy noencryption
  • Call ExtractTemporaryFile() before the corresponding Dependency_Add function:

    Pascal
    ExtractTemporaryFile('dxwebsetup.exe');

The dependencies are installed based on the system architecture. If you want to install 32-bit dependencies on a 64-bit system, you can force 32-bit mode like so:

Pascal
Dependency_ForceX86 := True;  // force 32-bit install of next dependencies
Dependency_AddVC2013;
Dependency_ForceX86 := False; // disable forced 32-bit install again

If you only deploy 32-bit binaries and dependencies, you can also instead just not define ArchitecturesInstallIn64BitMode in [Setup].

Dependencies

  • .NET
    • .NET Framework 3.5 Service Pack 1
    • .NET Framework 4.0
    • .NET Framework 4.5.2
    • .NET Framework 4.6.2
    • .NET Framework 4.7.2
    • .NET Framework 4.8.1
    • .NET Core 3.1 (Runtime, ASP.NET, Desktop)
    • .NET 5.0 (Runtime, ASP.NET, Desktop)
    • .NET 6.0 (Runtime, ASP.NET, Desktop)
    • .NET 7.0 (Runtime, ASP.NET, Desktop)
  • C++
    • Visual C++ 2005 Service Pack 1 Redistributable
    • Visual C++ 2008 Service Pack 1 Redistributable
    • Visual C++ 2010 Service Pack 1 Redistributable
    • Visual C++ 2012 Update 4 Redistributable
    • Visual C++ 2013 Update 5 Redistributable
    • Visual C++ 2015-2022 Redistributable
  • SQL
    • SQL Server 2008 R2 Service Pack 2 Express
    • SQL Server 2012 Service Pack 4 Express
    • SQL Server 2014 Service Pack 3 Express
    • SQL Server 2016 Service Pack 3 Express
    • SQL Server 2017 Express
    • SQL Server 2019 Express
    • SQL Server 2022 Express
  • Access
    • Access Database Engine 2010
    • Access Database Engine 2016
  • DirectX End-User Runtime
  • WebView2 Runtime

Credits

Thanks to the community for sharing many fixes and improvements. To contribute, please create a pull request.

This article was originally posted at https://github.com/DomGries/InnoDependencyInstaller

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
vanth3man14-Nov-11 22:23
vanth3man14-Nov-11 22:23 
Questionan attempt was made to expand the "app" constant before it was initialized Pin
ender4g18-Jul-11 3:03
ender4g18-Jul-11 3:03 
AnswerMessage Closed Pin
18-Jul-11 5:12
DomGries18-Jul-11 5:12 
GeneralRe: an attempt was made to expand the "app" constant before it was initialized Pin
ender4g18-Jul-11 22:23
ender4g18-Jul-11 22:23 
NewsLooking for testers for next version! [important] [modified] Pin
DomGries10-Jul-11 1:26
DomGries10-Jul-11 1:26 
GeneralRe: Looking for testers for next version! [important] Pin
GJSVB12323-Jul-11 14:33
GJSVB12323-Jul-11 14:33 
GeneralMessage Closed Pin
23-Jul-11 21:08
DomGries23-Jul-11 21:08 
GeneralRe: Looking for testers for next version! [important] Pin
GJSVB12324-Jul-11 12:32
GJSVB12324-Jul-11 12:32 
It seems to be Inno requiring the restart after msi31 is installed and in doing so kills the rest of the setup. Here's the steps I take. Using the latest scripts as downloaded from

http://code.google.com/p/stfx-wow/downloads/list

I comment out the following from the #define statements in setup.iss (my aim is to install a program that just requires .net fx 2.0):

//#define use_iis
//#define use_kb835732

//#define use_msi20
#define use_msi31
//#define use_msi45

//#define use_ie6

//#define use_dotnetfx11
//#define use_dotnetfx11lp

#define use_dotnetfx20
#define use_dotnetfx20lp

//#define use_dotnetfx35
//#define use_dotnetfx35lp

//#define use_dotnetfx40
//#define use_wic

//#define use_vc2010

//#define use_mdac28
//#define use_jet4sp8

//#define use_scceruntime

//#define use_sql2005express
//#define use_sql2008express

I then change the switches in msi31.iss to '/passive /norestart' and save. I can't find any MsgBox statement at all in function InstallProducts in products.iss.

This is what I am seeing:

function InstallProducts: InstallResult;
var
	ResultCode, i, productCount, finishCount: Integer;
begin
	Result := InstallSuccessful;
	productCount := GetArrayLength(products);

	if productCount > 0 then begin
		DependencyPage := CreateOutputProgressPage(CustomMessage('depinstall_title'), CustomMessage('depinstall_description'));
		DependencyPage.Show;

		for i := 0 to productCount - 1 do begin
			if (products[i].InstallClean and PendingReboot()) then begin
				Result := InstallRebootRequired;
				break;
			end;

			DependencyPage.SetText(FmtMessage(CustomMessage('depinstall_status'), [products[i].Title]), '');
			DependencyPage.SetProgress(i, productCount);

			if SmartExec(products[i], ResultCode) then begin
				//setup executed; ResultCode contains the exit code
				if (ResultCode = 0) then begin
					finishCount := finishCount + 1;
				end else if ((ResultCode = 3010) or products[i].MustRebootAfter) then begin
					//ResultCode 3010: A restart is required to complete the installation. This message indicates success.
					Result := InstallRebootRequired;
					break;
				end else begin
					Result := InstallError;
					break;
				end;
			end else begin
				Result := InstallError;
				break;
			end;
		end;

		//only leave not installed products for error message
		for i := 0 to productCount - finishCount - 1 do begin
			products[i] := products[i+finishCount];
		end;
		SetArrayLength(products, productCount - finishCount);

		DependencyPage.Hide;
	end;
end;



I then compile the script and put dotnetfx20sp2.exe and msi31.exe in MyProgramDependencies folder and copy this and MyProgram-4.0.exe to the clean install of windows XP SP2 (running on a VM). I disable the network adapter on this machine to check that no downloading is taking place.

I run MyProgram-4.0.exe and accept all the defaults so I get this before hitting the "install" button:

Install dependencies:
Windows Installer 3.1
.NET Framework 2.0 Service Pack 2

Destination location:
C:\Program Files\MyProgram

Start Menu folder:
MyProgram

Additional tasks:
Additional icons:
Create a desktop icon

I then see two dialogs with progress bars (too quick to read) then an Inno dialog box with title "Setup - MyProgram" saying "Preparing to install", then red cross icon and "Windows Installer 3.1 To complete the installation of MyProgram Setup must restart your computer. Would you likie to restart now?" There are two radio buttons with options "Yes, restart now." (selected) and "No, I will restart later." The dialog buttons are Back and Finish. I click finish and the machine restarts. After restart, the installer does not continue (no programs are running at all). In Control Panel - Add/Remove Programs, Windows Installer 3.1 is showing as installed but nothing else - no net fx 2.0 and no "MyProgam".

So, only Windows Installer is being installed, and then requiring a restart which kills the whole setup program.

'Hope that helps. I can send screen shots if that will make things clearer.

Regards,
GJS
GeneralMessage Closed Pin
24-Jul-11 22:13
DomGries24-Jul-11 22:13 
GeneralRe: Looking for testers for next version! [important] Pin
GJSVB12325-Jul-11 13:54
GJSVB12325-Jul-11 13:54 
GeneralMessage Closed Pin
25-Jul-11 20:38
DomGries25-Jul-11 20:38 
GeneralRe: Looking for testers for next version! [important] Pin
GJSVB12326-Jul-11 8:03
GJSVB12326-Jul-11 8:03 
GeneralRe: Looking for testers for next version! [important] Pin
Andrzej Lenkowski9-Sep-11 8:14
Andrzej Lenkowski9-Sep-11 8:14 
BugRe: Looking for testers for next version! [important] Pin
yvisek20-Sep-11 6:39
yvisek20-Sep-11 6:39 
GeneralRe: Looking for testers for next version! [important] [modified] Pin
Member 865677418-Feb-12 7:07
Member 865677418-Feb-12 7:07 
GeneralUnknown identifier 'init' Pin
HEMICRO20-May-11 13:42
HEMICRO20-May-11 13:42 
GeneralUnderstanding AddProduct parameters Pin
Hrizip3-Apr-11 11:15
Hrizip3-Apr-11 11:15 
GeneralMy vote of 5 Pin
Rei Masi23-Feb-11 1:49
Rei Masi23-Feb-11 1:49 
GeneralDownload Page Does Not Support Unicode At All Pin
Peter Lee7-Feb-11 17:34
Peter Lee7-Feb-11 17:34 
GeneralMy vote of 4 Pin
Ath_TonHu2-Jan-11 3:56
Ath_TonHu2-Jan-11 3:56 
General2011-01: Updated scripts available from my blog Pin
Ath_TonHu2-Jan-11 3:53
Ath_TonHu2-Jan-11 3:53 
GeneralCompatibility with Inno Setup 5.40 Pin
McoreD30-Dec-10 16:31
McoreD30-Dec-10 16:31 
GeneralRe: Compatibility with Inno Setup 5.40 Pin
joseph ni24-Jul-11 21:42
joseph ni24-Jul-11 21:42 
GeneralBug when using [Components] [modified] Pin
blaktro15-Dec-10 11:05
blaktro15-Dec-10 11:05 
GeneralRe: Bug when using [Components] Pin
blaktro16-Dec-10 2:16
blaktro16-Dec-10 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.