这是封装出来的针对.NET环境安装的精简流程

根据流程新建一个配置文件

教程都是很简单的,可以参考《InnoSetup 客户端程序打包教程

添加.NET安装基本的函数及辅助方法

在[Setup]模块下引用几个辅助文件

 1 //import dependency for .net
2 //isxdl operation
3 #include "dependency\isxdl.iss"
4 //;TYPES AND VARIABLES
5 #include "dependency\products.pas"
6 //about .net versions
7 #include "dependency\dotnetfxversion.iss"
isxdl.iss -- 引用了isxdl.dll并添加文件下载、安装函数
products.pas -- 版本的安装过程
dotnetfxversion.iss -- .net版本信息等相关函数

添加.NET版本引用及启动执行

以.net4.5.iss为例,添加了版本的信息及下载地址等(下载过程调用上个步骤中product.pas函数)

 1 [CustomMessages]
2 dotnetfx45_title=.NET Framework 4.5.2
3 dotnetfx45_size=68 MB
4
5 [Code]
6 const
7 dotnetfx45_url = 'http://download.microsoft.com/download/B/4/1/B4119C11-0423-477B-80EE-7A474314B347/NDP452-KB2901954-Web.exe';
8
9 procedure dotnetfx45(minVersion: Integer);
10 begin
11 if (dotnetfxspversion(NetFx4x, '') < minVersion) then
12 AddProduct('dotnetfx45.exe',
13 '/lcid ' + CustomMessage('lcid') + ' /passive /norestart',
14 CustomMessage('dotnetfx45_title'),
15 CustomMessage('dotnetfx45_size'),
16 dotnetfx45_url,
17 false, false, false);
18 end;

在[Setup]中添加要依赖的.NET版本:

1 [Setup]
2 //add .net4.5
3 #include "dependency\.net versions installation\dotnetfx45.iss"
4 #include "dependency\.net versions installation\dotnetfx46.iss"

添加定制语言项,如果安装包需要支持多语种,可以额外引用其它语言项进行选择。

 1 [CustomMessages]
2 DependenciesDir=MyProgramDependencies
3 WindowsServicePack=Windows %1 Service Pack %2
4 //固定英文安装语言
5 lcid=1033
6 depdownload_memo_title=Download dependencies
7 depinstall_memo_title=Install dependencies
8 depinstall_title=Installing dependencies
9 depinstall_description=Please wait while Setup installs dependencies on your computer.
10 depinstall_status=Installing %1...
11 depinstall_missing=%1 must be installed before setup can continue. Please install %1 and run Setup again.
12 depinstall_error=An error occured while installing the dependencies. Please restart the computer and run the setup again or install the following dependencies manually:%n
13 isxdl_langfile=""

安装.NET版本:

1 [Code]
2 function InitializeSetup(): Boolean;
3 begin
4 dotnetfx45(50); // install if version < 4.5.0
5 dotnetfx46(60); // install if version < 4.6.0
6 Result := true;
7 end;

需要什么版本,直接加一行代码就行~

Demo案例

点击安装后,会自动检测.NET环境,并执行缺失环境的安装。

安装成功后,就可以正常启动咯~

demo案例详见 https://github.com/Kybs0/InnoSetupAddNETVersionsDemo

参考文章:

InnoSetup打包 添加.NET环境安装的更多相关文章

  1. Sencha Toucha 2 —1.环境安装配置、在线打包、离线打包

    环境安装配置        1. 下载 1.1     Sencha Touch 下载 http://cdn.sencha.com/touch/sencha-touch-2.2.1-gpl.zip 1 ...

  2. vs.net打包(自动检测环境并安装.net framwork)

    vs.net打包程序或者制作安装程序时自动检测环境并安装.netframwork的设置方法之前我看过文档也做过,但是过一段时间又忘了,现在终于又找到方法了,还是把这个方法写下来吧,方便自己也方便大家将 ...

  3. QT环境安装VS2013(系统环境里设置QTDIR,并添加VS2013的BIN目录)

    QT环境安装VS2013 文件名 1.qt5.5.1 qt-opensource-windows-x86-msvc2013-5.5.1.exe 2.qt vs插件 3.qt-vs-addin-1.2. ...

  4. Java程序导出成.jar文件、生成.exe可执行文件及打包成可执行安装程序(可在无Java环境的计算机上运行)--以个人所得税计算器为例

    Java程序导出成.jar文件.生成.exe可执行文件及打包成可执行安装程序 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 需要准备的软件: jdk, ...

  5. python新手之一环境安装

    今天开始学习python,首先环境安装 1.在https://www.python.org/downloads/下载python2.X或者3.X(ps:这里建议下载32位的python ,因为64位p ...

  6. Java基础-配置开发环境-安装JDK

    Java基础-配置开发环境-安装JDK 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.计算机基础知识 1>.计算机的组成 计算机有硬件与软件组成. 2>.硬件: 硬 ...

  7. golang环境安装和配置

    go中环境安装 前言 最近在工作中需要新配置go环境,每次都要去网上查找教程,浪费时间,那么就自己总结下. 下载安装 linuxGolang官网下载地址:https://golang.org/dl/1 ...

  8. 无网环境安装docker之--rpm

    总体思路:找一台可以联网的linux,下载docker的RPM依赖包而不进行安装(yum localinstall),将所有依赖的rpm环境打包好,再在无网环境中解压逐一安装(rpm:  --forc ...

  9. 用Docker打包Python运行环境

    虽然Docker作为部署环境打包镜像的工具,和我的科研并没有直接的关系.但我觉得在项目中运用Docker来打包环境依赖也可以大大提高工作效率,于是准备专门学习一下Docker. 1. Docker基础 ...

随机推荐

  1. bbswitch与bumblebee配合使用

    !建议查阅并使用archwiki的bumblebee方案 ! 安装NONFREE驱动 1.在终端中输入以下命令来检查已安装的驱动版本(我这次装manjaro是hybird440) inxi -G 2. ...

  2. 【VUE】关于pinia代替vuex

    官方文档:https://pinia.web3doc.top/ 知乎讲解:https://zhuanlan.zhihu.com/p/533233367

  3. Cross Site Scripting DOM (XSS) 攻击jQuery append() 的处理方法

    做安全红线使用Fortify工具进行扫描时,jquery append会报Cross Site Scripting DOM风险.解决该问题有两种办法. 一.原生dom方式 使用JavaScript原生 ...

  4. 解决com.alibaba.excel.exception.ExcelGenerateException: Can not close IO.

    我在使用easycel导出到zip包中时,出现了这个问题.各种文件输出时产生的问题其实大同小异 查看了一些网上的文章,还有github上关于此bug的issue,总算是理清并解决了. 解决方法一 主要 ...

  5. TCP idle timeout 和TCP Keepalive 比较和分析

    TCP  idle timeout  和TCP Keepalive  是两个独立的功能. TCP  idle timeout  TCP  idle timeout  是系统TCP配置文件中的空闲超时设 ...

  6. MySQLdb安装

    yum seach MySQL-Python sudo yum install MySQL-python.x86_64 import MySQLdb

  7. kettle连接oracle

    连接oracle 10g 驱动classes12.jar 配置一下三项即可: 1.数据库名称:ip:端口/实例 2.用户名 3.密码

  8. git 更换远程连接

    原来的git仓库不可用,更换远程仓库 查看远程仓库地址 git remote -v 删除远程仓库 git remote rm origin 添加远程仓库地址 git remote add origin ...

  9. python中的反射机制

    转自https://www.cnblogs.com/renjie1105/p/15909285.html python反射简介 在做程序开发中,我们常常会遇到这样的需求:需要执行对象里的某个方法,或需 ...

  10. .net core 使用 Nlog 集成 exceptionless 配置文件

    nlog.config文件 安装nuget包: NLog.Web.AspNetCore Exceptionless.NLog 配置文件开始 <?xml version="1.0&quo ...