使用Inno Setup打包Winform程序

来源:互联网 发布:php bindto 编辑:程序博客网 时间:2024/05/17 09:29

使用Inno Setup打包Winform程序步骤:

①  注意:程序中所有引用的dll的属性“复制到本地”必须设置为true;

②  在VS中将解决方案配置从Debug改为Release,然后启动程序;

③  删除本地Release文件夹中的所有.pdb文件;

④  运行Inno Setup,选择“文件”菜单中的“新建”,一步一步操作(可设置打包程序名称、安装密码等),在其中的某一步选择“打包应用程序的.exe文件”、“Release文件夹”,最终将生成一个.iss脚本文件,保存并运行该脚本(必须保存,否则setup.exe无法生成成功),将在保存路径下生成一个Output文件夹,文件夹包含一个setup.exe文件(该.exe文件即程序的安装文件,可拷至其它目录然后运行安装)。

⑤  另外,对于保存到本地的.iss脚本,下次重新生成新的Release后可复用该脚本。


一个完整的iss文件示例:

; 脚本由 Inno Setup 脚本向导 生成!; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!#define MyAppName "xxx工具"#define MyAppVersion "1.0"#define MyAppPublisher "xxx"#define MyAppURL "http://www.xxx.com.cn/"#define MyAppExeName "xxx.exe"[Setup]; 注: AppId的值为单独标识该应用程序。; 不要为其他安装程序使用相同的AppId值。; (生成新的GUID,点击 工具|在IDE中生成GUID。)AppId={{25BEB8B0-7964-4045-B010-1E57BFEC692A}AppName={#MyAppName}AppVersion={#MyAppVersion};AppVerName={#MyAppName} {#MyAppVersion}AppPublisher={#MyAppPublisher}AppPublisherURL={#MyAppURL}AppSupportURL={#MyAppURL}AppUpdatesURL={#MyAppURL}DefaultDirName={pf}\{#MyAppName}DefaultGroupName={#MyAppName}OutputBaseFilename=xxxSetupIconFile=C:\Users\Administrator\Pictures\常用图标\新建文件夹\xxx_128X128.icoCompression=lzmaSolidCompression=yes[Languages]Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"[Tasks]Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";[UninstallDelete]Type: filesandordirs; Name: "{app}"[Files]Source: "E:\xxx\bin\Release\VoronoiTool.exe"; DestDir: "{app}"; Flags: ignoreversionSource: "E:\xxx\bin\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”[Icons]Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon[Run]Filename: "{app}\组件注册工具.exe"; Description:"运行 组件注册工具"; Flags: waituntilterminated postinstall skipifsilentFilename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[UninstallDelete]节点解决了安装程序卸载不干净的问题;

[Run]节点下的 组件注册工具.exe,Flags中的waituntilterminated保证了程序启动前组件的成功注册。


0 0
原创粉丝点击