当前位置: 首页 > news >正文

Revit二次开发_使用InnoSetup打包插件

InnoSetup是一个开源的安装包制作工具。

如果是简单的安装,例如安装流程只需要用户选一个安装路径,那么直接按引导操作就行,甚至不需要写代码。

如果有更复杂的需求,通常需要使用Inno支持的Pascal脚本进行自定义。

Inno打包程序脚本引导部分比较简单,资料网上也非常多,这里不再赘述。

对于Revit插件安装,特别的是最后要把addin文件复制到合适的位置,并且修改内容,指向对应文件,这部分网上内容相对少,记录一下。

下面三个示例,第一个是常规打包,

第二个与第一个类似,但增加了一个自定义页面,让用户设置一个资源存放的文件夹,计划用于存放依赖资源,

第三个则是通过调用一个外部程序来执行addin修改操作——如果对Pascal脚本不熟悉,可以用熟悉的语言写一个程序,然后在脚本中进行调用,从而执行类似操作

示例一(常规打包)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyRevitPlugin"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{782BAC7F-2B51-4378-B9CC-8559EB6E2CE7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=F:\packet_ex
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"// 调整dll路径;addin.template其实是常规的addin文件改了下文件名
[Files]
Source: "C:\Users\lisiting01\source\repos\MyRevitPlugin\MyRevitPlugin\bin\x64\Debug\MyRevitPlugin.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\addin\2019.addin.template"; DestDir: "{app}\addin"; Flags: ignoreversion[UninstallDelete]
Type: files; Name: "C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin"[Code]
varInstallPath: string;// CurStepChanged事件,安装阶段变化时触发
procedure CurStepChanged(CurStep: TSetupStep);
varAddinTemplateFile: string;AddinTargetFile: string;AddinContentANSI: AnsiString;AddinContentUCS: string;
begin// 到达 ssPostInstall 阶段时(安装后)触发事件if CurStep = ssPostInstall thenbegin// 安装路径InstallPath := ExpandConstant('{app}');// .addin 模板文件和目标文件路径AddinTemplateFile := InstallPath + '\addin\2019.addin.template';AddinTargetFile := 'C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin';// 注册 .addin 文件并指向到安装目录if LoadStringFromFile(AddinTemplateFile, AddinContentANSI) thenbeginAddinContentUCS := String(AddinContentANSI);StringChangeEx(AddinContentUCS, '{InstallPath}', InstallPath, True);SaveStringToFile(AddinTargetFile, AddinContentUCS, False);end;end;
end;

示例二(自定义页面)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyRevitPlugin"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{782BAC7F-2B51-4378-B9CC-8559EB6E2CE7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=F:\packet_ex
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"// 调整dll路径;addin.template其实是常规的addin文件改了下文件名
[Files]
Source: "C:\Users\lisiting01\source\repos\MyRevitPlugin\MyRevitPlugin\bin\x64\Debug\MyRevitPlugin.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\addin\2019.addin.template"; DestDir: "{app}\addin"; Flags: ignoreversion[UninstallDelete]
Type: files; Name: "{app}\Settings.ini"
Type: files; Name: "C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin"[Code]
varInstallPath: string;InputDirWizardPage: TInputDirWizardPage;// InitializeWizard事件,初始化安装向导时触发
procedure InitializeWizard;
begin// 创建自定义页面InputDirWizardPage := CreateInputDirPage(wpSelectDir, '设置资源文件夹路径', '这个文件夹将用于存放相关资源(族、贴图、渲染资源等)', '设置资源文件夹,然后点击下一步',True, 'BIMResource');InputDirWizardPage.Add('');InputDirWizardPage.Values[0] := ExpandConstant('{userdocs}')+'\BIMResource';end;// CurStepChanged事件,安装阶段变化时触发
procedure CurStepChanged(CurStep: TSetupStep);
varAddinTemplateFile: string;AddinTargetFile: string;AddinContentANSI: AnsiString;AddinContentUCS: string;ConfigFile: string;
begin// 到达 ssPostInstall 阶段时(安装后)触发事件if CurStep = ssPostInstall thenbegin// 安装路径InstallPath := ExpandConstant('{app}');// .addin 模板文件和目标文件路径AddinTemplateFile := InstallPath + '\addin\2019.addin.template';AddinTargetFile := 'C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin';// 配置文件路径ConfigFile := InstallPath + '\Settings.ini';// 注册 .addin 文件并指向到安装目录if LoadStringFromFile(AddinTemplateFile, AddinContentANSI) thenbeginAddinContentUCS := String(AddinContentANSI);StringChangeEx(AddinContentUCS, '{InstallPath}', InstallPath, True);SaveStringToFile(AddinTargetFile, AddinContentUCS, False);end;// 创建用户指定的资源文件夹CreateDir(InputDirWizardPage.Values[0]);// 设置配置文件SaveStringToFile(ConfigFile, 'BIMResource=' + InputDirWizardPage.Values[0] , False);end;
end;// 更新准备安装页的信息
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
varS: String;
beginS := '';S := S + '安装路径:' + NewLine;S := S + Space + ExpandConstant('{app}') + NewLine;S := S + NewLine;S := S + '资源路径:' + NewLine;S := S + Space + InputDirWizardPage.Values[0] + NewLine;Result := S;
end;

示例三(调用程序执行)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyRevitPlugin"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{782BAC7F-2B51-4378-B9CC-8559EB6E2CE7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=F:\packet_ex
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"// 调整dll路径;addin.template其实是常规的addin文件改了下文件名
[Files]
Source: "C:\Users\lisiting01\source\repos\MyRevitPlugin\MyRevitPlugin\bin\x64\Debug\MyRevitPlugin.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\SetupProgram.exe"; DestDir: "{app}"; Flags: ignoreversion[UninstallDelete]
Type: files; Name: "C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin"[Code]
varInstallPath: string;// CurStepChanged事件,安装阶段变化时触发
procedure CurStepChanged(CurStep: TSetupStep);
begin// 到达 ssPostInstall 阶段时(安装后)触发事件if CurStep = ssPostInstall thenbegin// 安装路径InstallPath := ExpandConstant('{app}');// 执行 SetupProgram.exeExec(ExpandConstant(InstallPath + '\SetupProgram.exe'), '', '', SW_SHOW, ewNoWait, ResultCode);end;
end;

资料:

InnoSetup文档:https://jrsoftware.org/ishelp.php

中文安装语言:https://github.com/kira-96/Inno-Setup-Chinese-Simplified-Translation

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • Vue2.0 项目实战篇\部署篇
  • B3-111-A 小型挂轨式巡检机器人:智能巡检的突破之
  • MyBatis 配置与测试方式
  • 【纯干货级教程】YOLOv7如何添加注意力机制?
  • 排序算法之折半插入排序
  • 算法的学习笔记—打印从 1 到最大的 n 位数
  • SQL Server 2022的索引
  • The Sandbox 游戏制作教程第 4 章|使用装备制作游戏,触发独特互动
  • 信创教育:培养未来科技创新的生力军
  • 八、OpenCVSharp 中图像阈值处理
  • uniapp预览图片uni.previewImage图片放大
  • Redis操作--RedisTemplate(二)StringRedisTemplate
  • 基于PSO-BP+BP多特征分类预测对比(多输入单输出) Matlab代码
  • 智能家居已是红海,竞争惨烈,或许高品质UI能增加产品辨识度
  • python结合csv和正则实现条件筛选数据统计分数
  • 11111111
  • ECMAScript入门(七)--Module语法
  • ES6简单总结(搭配简单的讲解和小案例)
  • JavaScript HTML DOM
  • Koa2 之文件上传下载
  • log4j2输出到kafka
  • Spring Security中异常上抛机制及对于转型处理的一些感悟
  • supervisor 永不挂掉的进程 安装以及使用
  • thinkphp5.1 easywechat4 微信第三方开放平台
  • 码农张的Bug人生 - 初来乍到
  • 一个6年java程序员的工作感悟,写给还在迷茫的你
  • 移动互联网+智能运营体系搭建=你家有金矿啊!
  • # 详解 JS 中的事件循环、宏/微任务、Primise对象、定时器函数,以及其在工作中的应用和注意事项
  • #我与Java虚拟机的故事#连载01:人在JVM,身不由己
  • $jQuery 重写Alert样式方法
  • (3)选择元素——(17)练习(Exercises)
  • (C)一些题4
  • (windows2012共享文件夹和防火墙设置
  • (二)丶RabbitMQ的六大核心
  • (二刷)代码随想录第16天|104.二叉树的最大深度 559.n叉树的最大深度● 111.二叉树的最小深度● 222.完全二叉树的节点个数
  • (附源码)springboot宠物管理系统 毕业设计 121654
  • (原)记一次CentOS7 磁盘空间大小异常的解决过程
  • (原創) 如何動態建立二維陣列(多維陣列)? (.NET) (C#)
  • .NET 8.0 发布到 IIS
  • .net framework4与其client profile版本的区别
  • .net2005怎么读string形的xml,不是xml文件。
  • .NET使用存储过程实现对数据库的增删改查
  • [ vulhub漏洞复现篇 ] ECShop 2.x / 3.x SQL注入/远程执行代码漏洞 xianzhi-2017-02-82239600
  • [2023年]-hadoop面试真题(一)
  • [240527] 谷歌 CEO 承认 AI 编造虚假信息问题难解(此文使用 @gemini 命令二次创作)| ICQ 停止运作
  • [C#][opencvsharp]opencvsharp sift和surf特征点匹配
  • [C++]类和对象【上篇】
  • [dart学习]第四篇:函数
  • [Git场景]常用工作场景演练
  • [IE技巧] 如何关闭Windows Server版IE的安全限制
  • [java/jdbc]插入数据时获取自增长主键的值
  • [Java] 模拟Jdk 以及 CGLib 代理原理
  • [leetcode 双指针]
  • [linux 驱动]misc设备驱动详解与实战
  • [NHibernate]条件查询Criteria Query