您当前的位置: 首页 >  visual studio

君子居易

暂无认证

  • 0浏览

    0关注

    210博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

在 Visual Studio 中使用 Inno Setup 创建安装

君子居易 发布时间:2021-07-08 18:53:18 ,浏览量:0

步骤 1:运行 Inno Setup 安装程序

在 Visual Studio 项目中使用 Inno Setup 作为构建后练习来创建安装程序包时,您将需要 Inno Setup 文件夹的内容,因为这将包含命令行可执行文件、dll 文件等。

如果你还没有这样做,你可以从这里得到它:

http://www.jrsoftware.org/

步骤 2:创建一个新的 Visual Studio 项目

右键单击解决方案并选择添加一个新的安装程序项目(类库)

3. 将“Inno Setup”内容添加到您的安装程序项目中

我喜欢在 Visual Studio 项目中保持所有内容完全独立,因此您是否愿意引用已安装到 Program Files 文件夹的 Inno 内容取决于您

右键单击并选择添加 > 新建文件夹。

在 Windows 资源管理器中,将现有的 Inno Setup 文件夹内容复制到您在 Visual Studio 项目中创建的文件夹中。复制内容后,我右键单击 Inno 文件夹并选择“添加现有项目”将它们添加到项目中:

第 4 步:添加设置 (*.iss) 文件

右键单击“安装程序”项目并选择“添加新项目”。

选择新的文本文件格式,但将文件重命名为“installer.iss”

第五步:修改安装程序*.iss文件

这里我们使用脚本文件的一个极简示例进行演示。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
; -- installer.iss --
 
[Setup]
AppName=InnoExampleInstaller
AppVersion=1.0
DefaultDirName={pf}\InnoExample
DefaultGroupName=InnoExample
Compression=lzma2
SolidCompression=yes
OutputBaseFilename=InnoExampleInstaller
OutputDir=.
UninstallDisplayIcon={app}\InnoExample.exe
UninstallDisplayName=InnoExample
 
[Files]
Source: "..\InnoExample\bin\Debug\InnoExample.exe"; DestDir: "{app}"
 
[Icons]
Name: "{group}\InnoExampleInstaller"; Filename: "{app}\InnoExample.exe"
Name: "{group}\Uninstall"; Filename: "{uninstallexe}"

信息:

{pf} – Program Files 目录的位置。 {app} – 应用程序目录 {group} – 开始菜单文件夹的路径

有关各种常量含义的更多信息,请参阅此链接:

http://www.jrsoftware.org/ishelp/index.php?topic=consts

步骤 6:在安装程序项目中设置构建后事件

右键单击“安装程序”项目并选择属性。 添加命令以在选定的 iss 文件上运行控制台应用程序“iscc.exe”作为构建后事件: $(ProjectDir)Inno\iscc.exe $(ProjectDir)installer.iss

第七步:设置项目构建依赖

右键单击“安装”项目文件夹并选择构建依赖项。确保“InnoExample”是“Installer”的依赖项:

第 8 步:构建项目

构建的输出如图所示,显示了设置的阶段以及安装程序的目的地:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1>------ Rebuild All started: Project: InnoExample, Configuration: Debug Any CPU ------
1>  InnoExample -> E:\CodeSamples\InnoExample\InnoExample\bin\Debug\InnoExample.exe
2>------ Rebuild All started: Project: Installer, Configuration: Debug Any CPU ------
2>  Installer -> E:\CodeSamples\InnoExample\Installer\bin\Debug\Installer.dll
2>  Inno Setup 5 Command-Line Compiler
2>  Copyright (C) 1997-2016 Jordan Russell. All rights reserved.
2>  Portions Copyright (C) 2000-2016 Martijn Laan
2>  Inno Setup Preprocessor
2>  Copyright (C) 2001-2004 Alex Yackimoff. All rights reserved.
2> 
2>  Compiler engine version: Inno Setup 5.5.9 (a)
2> 
2>  [ISPP] Preprocessing.
2>  [ISPP] Preprocessed.
2> 
2>  Parsing [Setup] section, line 4
2>  Parsing [Setup] section, line 5
2>  Parsing [Setup] section, line 6
2>  Parsing [Setup] section, line 7
2>  Parsing [Setup] section, line 8
2>  Parsing [Setup] section, line 9
2>  Parsing [Setup] section, line 10
2>  Parsing [Setup] section, line 11
2>  Parsing [Setup] section, line 12
2>  Parsing [Setup] section, line 13
2>  Reading file (WizardImageFile)
2>     File: E:\CodeSamples\InnoExample\Installer\Inno\WIZMODERNIMAGE.BMP
2>  Reading file (WizardSmallImageFile)
2>     File: E:\CodeSamples\InnoExample\Installer\Inno\WIZMODERNSMALLIMAGE.BMP
2>  Preparing Setup program executable
2>  Reading default messages from Default.isl
2>  Parsing [LangOptions], [Messages], and [CustomMessages] sections
2>     File: E:\CodeSamples\InnoExample\Installer\Inno\Default.isl
2>     Messages in script file
2>  Reading [Code] section
2>  Parsing [Icons] section, line 19
2>  Parsing [Icons] section, line 20
2>  Parsing [Files] section, line 16
2>     Reading version info: E:\CodeSamples\InnoExample\Installer\..\InnoExample\bin\Debug\InnoExample.exe
2>  Deleting InnoExampleInstaller.exe from output directory
2>  Creating setup files
2>     Compressing: E:\CodeSamples\InnoExample\Installer\..\InnoExample\bin\Debug\InnoExample.exe   (1.0.0.0)
2>     Compressing Setup program executable
2>     Updating version info
2> 
2> 
2>  Successful compile (0.827 sec). Resulting Setup program filename is:
2>  E:\CodeSamples\InnoExample\Installer\InnoExampleInstaller.exe
========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

请注意,安装程序包随后出现在所需位置:

在运行安装程序时,安装/卸载等将出现在开始菜单中,如下所示:

 

关注
打赏
1660814979
查看更多评论
立即登录/注册

微信扫码登录

0.0561s