Modular InnoSetup Dependency Installer[转]

Introduction

This article contains a modular InnoSetup install script that downloads (if setup files don't exist locally) and installs various dependencies like .NET Framework 1.1/2.0/3.5/4.0/4.6 or C++ Redistributable 2005/2008/2010/2012/2013/2015 on 32-bit and 64-bit Windows.

Background

Once upon a time, I needed an installer for my .NET applications. I knew that I could use the "genius" ClickOnce installer, but in my opinion it has a bad interface and is not very handy. Then I came across a script for InnoSetup that had everything I wanted, but unfortunately it was only for .NET 1.1. So, I spent quite a bit of time in InnoSetup to modify it to my needs and extending it vastly.

Details

The source code is written modular and is structured like this:



·setup.iss - contains the basic setup where you include the modules (products) you need. They need to be included at the top like #include "scripts\products\dotnetfx11.iss" and then you only have to call their main function inside the [Code] part like dotnetfx11();
·bin - contains the final output of the installer
·src - contains the application files of your program
·scripts
    ├products.iss - contains the shared code for the product scripts. You only have to change the [CustomMessages] part and [Files] part (inclusion of isxdl language files)
    ├isxdl - contains the downloader DLL for the setup (if there is something to download) and its language files (e.g. german.ini). This is the place where you can put your language files for the isxdl downloader in.
    ├products - contains the scripts for products which are required by the application (e.g. .NET Framework 2.0)
        ├dotnetfx11.iss - .NET Framework 1.1
        ├dotnetfx11lp.iss - .NET Framework 1.1 Language Pack
        ├dotnetfx11sp1.iss - .NET Framework 1.1 + Service Pack 1
        ├dotnetfx20.iss - .NET Framework 2.0
        ├dotnetfx20lp.iss - .NET Framework 2.0 Language Pack
        ├dotnetfx20sp1.iss - .NET Framework 2.0 + Service Pack 1
        ├dotnetfx20sp1lp.iss - .NET Framework 2.0 Service Pack 1 Language Pack
        ├dotnetfx20sp2.iss - .NET Framework 2.0 + Service Pack 2
        ├dotnetfx20sp2lp.iss - .NET Framework 2.0 Service Pack 2 Language Pack
        ├dotnetfx35.iss - .NET Framework 3.5
        ├dotnetfx35lp.iss - .NET Framework 3.5 Language Pack
        ├dotnetfx35sp1.iss - .NET Framework 3.5 + Service Pack 1
        ├dotnetfx35sp1lp.iss - .NET Framework 3.5 Service Pack 1 Language Pack
        ├dotnetfx40client.iss - .NET Framework 4.0 Client Profile
        ├dotnetfx40full.iss - .NET Framework 4.0 Full
        ├dotnetfx46.iss - .NET Framework 4.6
        ├ie6.iss - Internet Explorer 6
        ├iis.iss - Internet Information Services (just a check if it is installed)
        ├jet4sp8.iss - Jet 4 + Service Pack 8
        ├kb835732.iss - Security Update (KB835732) which is required by .NET Framework 2.0 Service Pack 1 on Windows 2000 Service Pack 4
        ├mdac28.iss - Microsoft Data Access Components (MDAC) 2.8
        ├msi20.iss - Windows Installer 2.0
        ├msi31.iss - Windows Installer 3.1
        ├msi45.iss - Windows Installer 4.5
        ├sql2005express.iss - SQL Server 2005 Express + Service Pack 3
        ├sql2008express.iss - SQL Server 2008 Express R2
        ├sqlcompact35sp2.iss - SQL Server Compact 3.5 + Service Pack 2
        ├vcredist2005.iss - Visual C++ 2005 Redistributable
        ├vcredist2008.iss - Visual C++ 2008 Redistributable
        ├vcredist2010.iss - Visual C++ 2010 Redistributable
        ├vcredist2012.iss - Visual C++ 2012 Redistributable
        ├vcredist2013.iss - Visual C++ 2013 Redistributable
        ├vcredist2015.iss - Visual C++ 2015 Redistributable
        ├wic.iss - Windows Imaging Component
        ├winversion.iss - helper functions to determine the installed Windows version
        ├fileversion.iss - helper functions to determine the version of a file
        ├stringversion.iss - helper functions to correctly parse a version string
        ├dotnetfxversion.iss - helper functions to determine the installed .NET Framework version including service packs
        ├msiproduct.iss - helper functions to check for installed msi products

Most of the time you need to tweak the setup.iss because of different Windows version checks and inclusion of your required dependencies.

If a dependency (product) is not installed, the script checks if the product's setup exists inside the dependencies directory which is configurable in products.iss. By default it is: .\MyProgramDependencies. If they don't exist there, it tries to download them (except for Windows service packs). This means a support for offline installing via CD or DVD is also possible.

The installation routine of the dependencies is automatic, and they run in quiet or semi quiet mode. Therefore no user interaction is needed (except for Internet Explorer 6). This setup script uses [CostumMessages] so that you can easily add multi-language support to your setup and easily configure settings (like the offline dependencies directory) without looking at the [Code] part.

Applications used for the script are:

·Inno Setup - setup engine (version 5.5.6)
·ISTool - extends Inno Setup but I just needed the isxdl.dll downloader (version 5.3.0)


---------------------------------------------------- 安装示例 ----------------------------------------------------










[1].原文链接:http://www.codeproject.com/Articles/20868/NET-Framework-Installer-for-InnoSetup
[2].源码下载:http://www.mzwu.com/pic/201611/innodependencyinstaller.zip
[3].中文译文:http://www.cnblogs.com/yplong/p/4261244.html

评论: 0 | 引用: 0 | 查看次数: 5635
发表评论
登录后再发表评论!