Click here to Skip to main content
16,012,468 members
Articles / Programming Languages / SQL

Inno Setup Dependency Installer

Rate me:
Please Sign up or sign in to vote.
4.91/5 (192 votes)
7 Aug 2023CPOL2 min read 1.8M   25K   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

 
General.NET Framework 2.0 again Pin
User 151565625-Jun-08 22:02
User 151565625-Jun-08 22:02 
GeneralRe: .NET Framework 2.0 again Pin
spif200115-Jul-08 1:05
spif200115-Jul-08 1:05 
GeneralRe: .NET Framework 2.0 again Pin
pjain0129-Dec-08 19:42
pjain0129-Dec-08 19:42 
General.NET Framework 3.5 Pin
ab-tools28-May-08 23:51
ab-tools28-May-08 23:51 
QuestionThanks! + a language issue and a plea Pin
spif20011-Apr-08 23:09
spif20011-Apr-08 23:09 
GeneralRe: Thanks! + a language issue and a plea Pin
spif20014-Apr-08 4:38
spif20014-Apr-08 4:38 
GeneralRe: Thanks! + a language issue and a plea Pin
ab-tools28-May-08 23:55
ab-tools28-May-08 23:55 
GeneralRe: Thanks! + a language issue and a plea [modified] Pin
spif200129-May-08 4:00
spif200129-May-08 4:00 
Sure - but I have moved a lot of things around. Hope you can figure it out. Smile | :)

I have made it so, that any new application installer I make, have to have some ekstra includes. Heres an example of a Test Installer's main iss file:
#define ApplicationName "DotNetTest"

#include "C:\Inno Installers\Common Inno Files\CustomLanguage\CustomLanguage.iss"
#include "C:\Inno Installers\Common Inno Files\ISXDL\isxdl.iss"
#include "C:\Inno Installers\Common Inno Files\Defines\Defines.iss"
#include "C:\Inno Installers\Common Inno Files\DotNet 3.5\DotNet35.iss"

[Setup]
AppName=TestDotNet35
AppVerName=TestDotNet35 v1.0
DefaultDirName=C:\TestDotNet35
DefaultGroupName=TestDotNet35
OutputBaseFilename=TestDotNet35 v1.0
OutputDir=C:\Inno Installers\Test installers\Compiled tests
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin

[Files]
Source: C:\some.exe; DestDir: {app};

[UninstallDelete]
Type: filesandordirs; Name: {app}

I have a rather large hierarchy of iss files, because I love to reuse code.

Just as in this article's installer, I include the ISXDL.iss file.

All language specific messages I have in a CustomLanguage.iss file which looks like this:
#include "C:\Inno Installers\Common Inno Files\CustomLanguage\English\CustomEnglish.iss"
#include "C:\Inno Installers\Common Inno Files\CustomLanguage\German\CustomGerman.iss"
#include "C:\Inno Installers\Common Inno Files\CustomLanguage\Danish\CustomDanish.iss"
#include "C:\Inno Installers\Common Inno Files\CustomLanguage\Swedish\CustomSwedish.iss"

[Languages]
;Name: english; MessagesFile: compiler:Default.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\English\{#ApplicationName} license\English.txt
;Name: german; MessagesFile: compiler:Languages\German.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\German\{#ApplicationName} license\German.txt
;Name: danish; MessagesFile: compiler:Languages\Danish.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\Danish\{#ApplicationName} license\Danish.txt
;Name: swedish; MessagesFile: compiler:Languages\Swedish.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\Swedish\{#ApplicationName} license\Swedish.txt

Name: english; MessagesFile: compiler:Default.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\English\General License.rtf
Name: german; MessagesFile: compiler:Languages\German.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\German\General License.rtf
Name: danish; MessagesFile: compiler:Languages\Danish.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\Danish\General License.rtf
Name: swedish; MessagesFile: compiler:Languages\Swedish.isl; LicenseFile: C:\Inno Installers\Common Inno Files\CustomLanguage\Swedish\General License.rtf

[CustomMessages]
DependenciesDir=Prerequisites
MSI20Title=Windows Installer 2.0
MSI31Title=Windows Installer 3.1
IE6Title=Internet Explorer 6
MDACTitle=MDAC 2.8
DOTNET20Title=Microsoft .NET Framework 2.0
DOTNET20SP1Title=Microsoft .NET Framework 2.0 Service Pack 1
DOTNET35Title=Microsoft .NET Framework 3.5
SqlExpress2005SP2Title=Microsoft SQL Server 2005 Express Edition Service Pack 2
Sql2005XMOTitle=Microsoft SQL Server 2005 Management Objects Collection

This language file includes country specific language iss files, where the english version looks like this:
[CustomMessages]
english.Install_CloseRunningProgram=An instance of {#ApplicationName} is already running. Please close the running {#ApplicationName} application and run {#ApplicationName} Setup again.
english.Uninstall_CloseRunningProgram=An instance of {#ApplicationName} is running. Please close the running {#ApplicationName} application and try uninstalling {#ApplicationName} again.
english.OldUninstall_1={#ApplicationName} Setup found an old {#ApplicationName} program on the system, which MUST be removed before this installation can continue.
english.OldUninstall_2=Do you wish to remove this old {#ApplicationName} program now?
english.OldUninstallFail=Could not uninstall the old {#ApplicationName} installation! Please uninstall {#ApplicationName} via Add/Remove programs in the Control Panel.
english.InstallFor=Install {#ApplicationName} for:
english.Everyone=Everyone
english.JustMe=Just me
english.DependenciesDownloadTitle=Download Dependencies
english.DependenciesInstallTitle=Install Dependencies
english.Win2000Sp3Msg=Windows 2000 Service Pack 3 must be installed before {#ApplicationName} Setup can continue. Please install Windows 2000 Service Pack 3 and run {#ApplicationName} Setup again.
english.WinXPSp2Msg=Windows XP Service Pack 2 must be installed before {#ApplicationName} Setup can continue. Please install Windows XP Service Pack 2 and run {#ApplicationName} Setup again.
english.SqlExpressSP2Msg={#ApplicationName} Setup could not find a Microsoft SQL Server on the computer.%n%nDo you wish to install Microsoft SQL Server 2005 Express Edition Service Pack 2 during the {#ApplicationName} installation?
english.DownloadMsg1=The following applications are required before {#ApplicationName} Setup can continue:
english.DownloadMsg2=Download and install now?
english.SqlExpress2005SP2DownloadSize=~37.5 MB
english.Sql2005XMODownloadSize=~9.2 MB
english.MSI20DownloadSize=~1.7 MB
english.MSI31DownloadSize=~2.5 MB
english.IE6DownloadSize=~46 MB
english.MDACDownloadSize=~5.4 MB
english.DOTNET20DownloadSize=~23 MB
english.DOTNET20SP1DownloadSize=~23.5 MB
english.DOTNET35DownloadSize=~200 MB
english.SqlExpress2005SP2InstallMsg=Installing Microsoft SQL Server 2005 Express Edition Service Pack 2... (May take a few minutes)
english.Sql2005XMOInstallMsg=Installing Microsoft SQL Server 2005 Management Objects Collection... (May take a few minutes)
english.MSI20InstallMsg=Installing Windows Installer 2.0... (May take a few minutes)
english.MSI31InstallMsg=Installing Windows Installer 3.1... (May take a few minutes)
english.IE6InstallMsg=Installing Internet Explorer 6... (May take a few minutes)
english.DOTNET20InstallMsg=Installing Microsoft .NET Framework 2.0... (May take a few minutes)
english.DOTNET20SP1InstallMsg=Installing Microsoft .NET Framework 2.0 Service Pack 1... (May take a few minutes)
english.DOTNET35InstallMsg=Installing Microsoft .NET Framework 3.5... (May take a few minutes)

I also have a defines.iss file with my URL's in looking like this
#define MSI20URL "'http://download.microsoft.com/download/WindowsInstaller/Install/2.0/W9XMe/EN-US/InstMsiA.exe'"
#define MSI31URL "'http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec7baf996f46/WindowsInstaller-KB893803-v2-x86.exe'"
#define IE6URL "'http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/ie6setup.exe'"
#define DotNet11URL "'http://download.microsoft.com/download/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe'"
#define DotNet20URL "'http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe'"
#define DotNet20SP1URL "'***Placed on local server***'"
#define DotNet35URL "'http://download.microsoft.com/download/6/0/f/60fc5854-3cb8-4892-b6db-bd4f42510f28/dotnetfx35.exe'"
#define SQLExpress2005SP2URL "'http://go.microsoft.com/fwlink/?LinkId=65212'"
#define SQL2005XMOURL "'http://download.microsoft.com/download/4/4/D/44DBDE61-B385-4FC2-A67D-48053B8F9FAD/SQLServer2005_XMO.msi'"

...and finally the dotnet35.iss file which was your primary interest:
[Run]
Filename: {ini:{tmp}\dep.ini,install,msi31}; Description: {cm:MSI31Title}; StatusMsg: {cm:MSI31InstallMsg}; Parameters: "/quiet"; Flags: skipifdoesntexist
Filename: {ini:{tmp}\dep.ini,install,dotnet35}; Description: {cm:DOTNET35Title}; StatusMsg: {cm:DOTNET35InstallMsg}; Parameters: "/Q /T:{tmp}\dotnetfx35 /C:""install /qb"""; Flags: skipifdoesntexist


[Code]
var
dotnet35Path, msi31Path, neededDependenciesDownloadMemo, neededDependenciesInstallMemo, neededDependenciesDownloadMsg: string;
downloadNeeded: boolean;

// get Windows Installer version
procedure DecodeVersion(const Version: cardinal; var a, b : word);
begin
  a := word(Version shr 16);
  b := word(Version and not $ffff0000);
end;

function IsMinMSIAvailable(HV:Integer; NV:Integer ): boolean;
var
  Version, dummy : cardinal;
  MsiHiVer, MsiLoVer : word;

begin
  Result:=(FileExists(ExpandConstant('{sys}\msi.dll'))) and (GetVersionNumbers(ExpandConstant('{sys}\msi.dll'), Version, dummy));
  DecodeVersion(Version, MsiHiVer, MsiLoVer);
  Result:= (Result) and (MsiHiVer >= HV) and (MsiLoVer >= NV);
end;

function InitializeSetup(): Boolean;
var
  WindowsVersion: TWindowsVersion;

begin
  //if IsModuleLoaded( '{#ExeName}' ) then begin
  //  MsgBox(CustomMessage('Install_CloseRunningProgram'), mbError, MB_OK);
  //  Result := false;
  //  exit;
  //end;
  
  if not WizardSilent() then begin
    GetWindowsVersionEx(WindowsVersion);
    Result := true;

    // Check for Windows XP SP2
    if WindowsVersion.NTPlatform and (WindowsVersion.Major = 5) and (WindowsVersion.Minor = 1) and (WindowsVersion.ServicePackMajor < 2) then begin
      MsgBox(CustomMessage('WinXPSp2Msg'), mbError, MB_OK);
      Result := false;
      exit;
    end;

    // Check for required Windows Installer 3.0 on Windows 2000, XP, Server 2003, Vista or higher
    if WindowsVersion.NTPlatform and (WindowsVersion.Major >= 5) and (not IsMinMSIAvailable(3,0)) then begin
      neededDependenciesInstallMemo := neededDependenciesInstallMemo + ' ' + CustomMessage('MSI31Title') + #13;
      msi31Path := ExpandConstant('{src}') + '\' + CustomMessage('DependenciesDir') + '\WindowsInstaller-KB893803-v2-x86.exe';
      if not FileExists(msi31Path) then begin
        msi31Path := ExpandConstant('{tmp}\msi31.exe');
        if not FileExists(msi31Path) then begin
          neededDependenciesDownloadMemo := neededDependenciesDownloadMemo + ' ' + CustomMessage('MSI31Title') + #13;
          neededDependenciesDownloadMsg := neededDependenciesDownloadMsg + CustomMessage('MSI31Title') + ' (' + CustomMessage('MSI31DownloadSize') + ')' + #13;
          isxdl_AddFile({#MSI31URL}, msi31Path);
          downloadNeeded := true;
        end;
      end;
      SetIniString('install', 'msi31', msi31Path, ExpandConstant('{tmp}\dep.ini'));
    end;

    // Check for required dotnetfx 3.5 installation
    if (not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5')) then begin
      neededDependenciesInstallMemo := neededDependenciesInstallMemo + ' ' + CustomMessage('DOTNET35Title') + #13;
      dotnet35Path := ExpandConstant('{src}') + '\' + CustomMessage('DependenciesDir') + '\dotnetfx35.exe';
      if not FileExists(dotnet35Path) then begin
        dotnet35Path := ExpandConstant('{tmp}\dotnetfx35.exe');
        if not FileExists(dotnet35Path) then begin
          neededDependenciesDownloadMemo := neededDependenciesDownloadMemo + ' ' + CustomMessage('DOTNET35Title') + #13;
          neededDependenciesDownloadMsg := neededDependenciesDownloadMsg + CustomMessage('DOTNET35Title') + ' (' + CustomMessage('DOTNET35DownloadSize') + ')' + #13;
          isxdl_AddFile({#DotNet35URL}, dotnet35Path);
          downloadNeeded := true;
        end;
      end;
      SetIniString('install', 'dotnet35', dotnet35Path, ExpandConstant('{tmp}\dep.ini'));
    end;

  end;
end;

function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;

begin
  Result := true;
  if CurPage = wpReady then begin
    hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
    if downloadNeeded then
      if MsgBox(CustomMessage('DownloadMsg1') + #13 + neededDependenciesDownloadMsg + #13 + CustomMessage('DownloadMsg2'), mbConfirmation, MB_YESNO) = IDNO then Result := false
    else if isxdl_DownloadFiles(hWnd) = 0 then Result := false;
  end;
end;

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
  s: string;

begin
  if neededDependenciesDownloadMemo <> '' then s := s + CustomMessage('DependenciesDownloadTitle') + ':' + NewLine + neededDependenciesDownloadMemo + NewLine;
  if neededDependenciesInstallMemo <> '' then s := s + CustomMessage('DependenciesInstallTitle') + ':' + NewLine + neededDependenciesInstallMemo + NewLine;
  s := s + MemoDirInfo + NewLine + NewLine + MemoGroupInfo
  if MemoTasksInfo <> '' then s := s + NewLine + NewLine + MemoTasksInfo;
  Result := s
end;


I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.

modified on Thursday, May 29, 2008 10:56 AM

GeneralRe: Thanks! + a language issue and a plea Pin
ab-tools29-May-08 4:32
ab-tools29-May-08 4:32 
GeneralRe: Thanks! + a language issue and a plea Pin
spif200129-May-08 4:50
spif200129-May-08 4:50 
GeneralRe: Thanks! + a language issue and a plea Pin
ab-tools29-May-08 5:19
ab-tools29-May-08 5:19 
GeneralRe: Thanks! + a language issue and a plea Pin
spif200129-May-08 7:05
spif200129-May-08 7:05 
Question#include and the prerequisite routines Pin
voilapjr17-Mar-08 5:56
voilapjr17-Mar-08 5:56 
GeneralMessage Closed Pin
17-Mar-08 10:23
DomGries17-Mar-08 10:23 
GeneralRe: #include and the prerequisite routines Pin
voilapjr17-Mar-08 13:32
voilapjr17-Mar-08 13:32 
GeneralAnother path to netframework 2.0 Pin
PetLahev16-Mar-08 12:25
PetLahev16-Mar-08 12:25 
GeneralWow, thanks. Pin
AndrewVos4-Mar-08 1:22
AndrewVos4-Mar-08 1:22 
QuestionWhere is Src Code !? Pin
Ehsan Golkar22-Feb-08 21:36
Ehsan Golkar22-Feb-08 21:36 
GeneralWindows Vista [modified] Pin
Member 10817063-Dec-07 14:44
Member 10817063-Dec-07 14:44 
GeneralWinXP SP2 & NET20 Pin
J Sullivan27-Oct-07 21:40
J Sullivan27-Oct-07 21:40 
GeneralMessage Closed Pin
27-Oct-07 23:18
DomGries27-Oct-07 23:18 
GeneralMessage Closed Pin
27-Oct-07 23:31
DomGries27-Oct-07 23:31 
AnswerRe: WinXP SP2 & NET20 Pin
J Sullivan28-Oct-07 0:35
J Sullivan28-Oct-07 0:35 
GeneralNice Pin
Paul Conrad27-Oct-07 9:00
professionalPaul Conrad27-Oct-07 9:00 
GeneralMessage Closed Pin
27-Oct-07 9:06
DomGries27-Oct-07 9:06 

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.