• InnoSetup打包 添加.NET环境安装


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

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

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

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

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

     1 //import dependency for .net
     2 //isxdl operation  
     3 #include "dependencyisxdl.iss"
     4 //;TYPES AND VARIABLES
     5 #include "dependencyproducts.pas"
     6 //about .net versions
     7 #include "dependencydotnetfxversion.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 installationdotnetfx45.iss" 
    4 #include "dependency.net versions installationdotnetfx46.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

    参考文章:

  • 相关阅读:
    windows 下搭建安装 sass
    mac 下搭建安装 sass
    解决 document.getElementsByClassName 在 IE8 下的兼容下的问题
    placeholder颜色
    文本两端对齐
    css3之border-color
    pip 安装自己开发模块 边调试边修改
    Go语言格式化字符
    遍历修改django bootstrap form 为 django bootstrap3
    git 合并两个仓库
  • 原文地址:https://www.cnblogs.com/kybs0/p/13806494.html
Copyright © 2020-2023  润新知