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

Inno Setup 创建Revit安装包

之前通过NSIS打包文件后来发现Inno Setup,使用了一下发现相较于NSIS个人感觉Inno稍微好一点,整个操作界面会比NSIS要简洁许多,有汉化版可以添加我这里用的是英文原版

向导设置

  1. 安装后创建新的文件向导 File-> New
    在这里插入图片描述
  2. 点击Next进入设置界面

在这里插入图片描述
因为打包的安装包大部分是放在指定的文件夹中所以选择文件夹
在这里插入图片描述
3. 因为Revit插件是基于Reivt二次开发的插件所以没有启动项勾选下面的即可,如果有其他的文件也可以,这个地方我没有尝试加入文件夹,后续的文件夹我直接再脚本中新增
在这里插入图片描述
同样因为没有启动项我们也不需要创建开始菜单,这里点掉就可以了
在这里插入图片描述
4. 添加许可文件等信息
在这里插入图片描述
5. 添加安装权限这个位置后续也是可以通过脚本编辑
在这里插入图片描述
6. 选择语言,因为我没有安装汉化包所以只有选择英文
在这里插入图片描述
6. 其他设置
在这里插入图片描述
7. 完成,之后进入脚本编辑内容
在这里插入图片描述

脚本设置

具体的内容可以看Inno的API进行学习操作,这里说一下我用到的节点

  1. 有时我们需要将安装包中某些文件安装到系统路径中,Inno这里提供了一些系统路径的节点,可以看API中Constants节点,其中
    • {app} 用户安装路径
    • {localappdata} C:\Users\user\AppData\Local
    • {appdata} C:\Users\xu.lanhui\AppData\Roaming
  2. Source
    这里我是用Source添加了公司内部的登录确认工具,并让其安装到单独的路径中
Source: "C:\Users\xu.lanhui\Desktop\registor\*";DestDir:"{localappdata}\***\registor" ; Flags: ignoreversion recursesubdirs createallsubdirs
  1. [Run] 复制多个addin文件
    因为可以调用外部应用程序,可以使用擅长的语言写文件Copy的程序,使用Inno调用即可,下面是我的传入参数
[Run]
Filename: "{app}\CopyFiles.exe" ;Description:"修改文件" ; Parameters:"""{app}"""; StatusMsg: "正在配置信息"; Flags: runhidden 

全部脚本编码及C#复制addin到版本文件

  1. Inno脚本编码
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "BiMass"
#define MyAppVersion "1.4.2"
#define MyAppPublisher "TYDI"

[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={{3B7C7466-9BA0-44B3-80D8-87DDF9997572}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=D:\000 Development&TemplateFloder\Panel\Document.rtf
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=D:\000 Development&TemplateFloder\Panel\Output
OutputBaseFilename=Setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
PrivilegesRequired=admin
UsedUserAreasWarning = no

[Dirs]
Name: "{localappdata}\***\registor"

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]

Source: "D:\000 Development&TemplateFloder\Panel\Panel\Install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\user\Desktop\registor\*";DestDir:"{localappdata}\TengYuanTmp\registor" ; Flags: ignoreversion recursesubdirs createallsubdirs

; NOTE: Don't use "Flags: ignoreversion" on any shared system files


[Run]
Filename: "{app}\CopyFiles.exe" ;Description:"修改文件" ; Parameters:"""{app}"""; StatusMsg: "正在配置信息"; Flags: runhidden 

  1. C# 复制许可文件到版本addin中
    • 这事我的文件架构
      在这里插入图片描述
    • code
// See https://aka.ms/new-console-template for more information

using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

Console.WriteLine("Start Changing");
string path = string.Empty;
if(args.Length < 1)
{
    path = System.Environment.CurrentDirectory;
}
else
{
    path = args[0];
}


Console.WriteLine(path);
try
{
    var localFile = @".\ProductName.addin";
    var strContent = File.ReadAllText(localFile);

    CopyFiles(strContent, path);
}
catch (Exception e)
{
    
    Console.WriteLine(e.ToString());
    throw;
}
Console.WriteLine("Done");
//Console.ReadKey();
return;


bool CopyFiles(string strContent, string targetPath)
{

    if (strContent == null) throw new ArgumentNullException(nameof(strContent));
    if (targetPath == null) throw new ArgumentNullException(nameof(targetPath));

    int[] versions = new[] { 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 };
    // 将数据copy到其他版本文件中,如果路径下不存在该文件夹则创建新文件夹
    //const string localProgramDataPath = @"C:\ProgramData\Autodesk\Revit\";
    const string localReplacePath = @"E:\\Productname\\RibbonPanel\\Panel\\bin\\Debug\\Panel.dll";
    const string localDataPath = @"C:\ProgramData\Autodesk\Revit\Addins";
    foreach (int version in versions)
    {
        string? content = strContent.Clone() as string;
        var fullPath = @$"{targetPath}\{version}";//代表用户的安装路径
        Console.WriteLine($"fullPath:{fullPath}");
        var localFullPath = @$"{localDataPath}\{version}";//代表peogramdata文件夹路径
        //查找C盘路径是否提前创建该文件夹,如果没有则新建
        if (!File.Exists(localFullPath))
        {
            Directory.CreateDirectory(localFullPath);
            Console.WriteLine(localFullPath);
        }
        //查找安装位置是否有着指定版本安装文件,没有的话跳过
        if (Directory.Exists(fullPath))
        {
            if (content != null)
            {
                content = Regex.Replace(content, @localReplacePath, fullPath + @$"\Productname_{version}.dll");
                Console.WriteLine(content);
                File.WriteAllText(localFullPath + @"\Productname.addin", content);
            }
        }
        

        //Console.WriteLine($"localPath:{fullPath}");
    }

    return false;
}

相关文章:

  • Windows和Linux使用FRP实现内网穿透
  • c++代码如何实现在win/linux下创建编译及部署后台服务,并管理其他服务
  • UI 自动化测试应不应该投入?有没有前途?怎样做最明智?
  • 股票量化交易有什么优势?
  • 元宇宙电商-NFG系统,是如何用数字藏品平台,促进新营销的?
  • thunderbird102编译-环境搭建(1)
  • curl用法:查看响应时间
  • 房地产基础知识!!!
  • 写一个简单食用的拦截器
  • 算法竞赛进阶指南 0x68 二分图的匹配
  • 【无标题】数字ic设计|ic芯片设计全流程
  • Stable Diffusion搭建全过程记录,生成自己的专属艺术照
  • 【iOS自动化测试】第二章:环境安装
  • 源码安装LAMT架构
  • 重要文件即时搞定,不用插电就能打印,汉印MT800移动便携打印机上手
  • Github访问慢解决办法
  • Linux Process Manage
  • node和express搭建代理服务器(源码)
  • Rancher-k8s加速安装文档
  • Redis 懒删除(lazy free)简史
  • TypeScript实现数据结构(一)栈,队列,链表
  • Vue 重置组件到初始状态
  • 初识 webpack
  • 个人博客开发系列:评论功能之GitHub账号OAuth授权
  • 官方解决所有 npm 全局安装权限问题
  • 猴子数据域名防封接口降低小说被封的风险
  • 每个JavaScript开发人员应阅读的书【1】 - JavaScript: The Good Parts
  • 容器服务kubernetes弹性伸缩高级用法
  • 三分钟教你同步 Visual Studio Code 设置
  • 什么是Javascript函数节流?
  • 找一份好的前端工作,起点很重要
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • Oracle Portal 11g Diagnostics using Remote Diagnostic Agent (RDA) [ID 1059805.
  • const的用法,特别是用在函数前面与后面的区别
  • mysql 慢查询分析工具:pt-query-digest 在mac 上的安装使用 ...
  • 新年再起“裁员潮”,“钢铁侠”马斯克要一举裁掉SpaceX 600余名员工 ...
  • ​总结MySQL 的一些知识点:MySQL 选择数据库​
  • #Lua:Lua调用C++生成的DLL库
  • #每日一题合集#牛客JZ23-JZ33
  • #我与Java虚拟机的故事#连载03:面试过的百度,滴滴,快手都问了这些问题
  • (2/2) 为了理解 UWP 的启动流程,我从零开始创建了一个 UWP 程序
  • (AtCoder Beginner Contest 340) -- F - S = 1 -- 题解
  • (翻译)Quartz官方教程——第一课:Quartz入门
  • (力扣题库)跳跃游戏II(c++)
  • (五)IO流之ByteArrayInput/OutputStream
  • (续)使用Django搭建一个完整的项目(Centos7+Nginx)
  • (转)shell中括号的特殊用法 linux if多条件判断
  • .NET 应用启用与禁用自动生成绑定重定向 (bindingRedirect),解决不同版本 dll 的依赖问题
  • .NET 中各种混淆(Obfuscation)的含义、原理、实际效果和不同级别的差异(使用 SmartAssembly)
  • .NET设计模式(2):单件模式(Singleton Pattern)
  • .net使用excel的cells对象没有value方法——学习.net的Excel工作表问题
  • :O)修改linux硬件时间
  • @ResponseBody
  • [ linux ] linux 命令英文全称及解释
  • [<MySQL优化总结>]