192 lines
6.1 KiB
Plaintext
192 lines
6.1 KiB
Plaintext
|
|
; 脚本由 Inno Setup 脚本向导生成。
|
|||
|
|
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
|||
|
|
|
|||
|
|
; 定义应用程序的名称
|
|||
|
|
;#define MyAppName "建模工具集"
|
|||
|
|
; 定义应用程序的版本号
|
|||
|
|
;#define MyAppVersion "1.0.0.0"
|
|||
|
|
; 定义应用程序的发布者
|
|||
|
|
#define MyAppPublisher "shrlalgo"
|
|||
|
|
; 定义应用程序的网址
|
|||
|
|
#define MyAppURL "https://www.shrlalgo.com"
|
|||
|
|
|
|||
|
|
#ifndef MyAppVersion
|
|||
|
|
#define MyAppVersion "1.0.0"
|
|||
|
|
#endif
|
|||
|
|
#ifndef MyAppName
|
|||
|
|
#define MyAppName "建模工具集"
|
|||
|
|
#endif
|
|||
|
|
#ifndef MyDllName
|
|||
|
|
#define MyDllName "ShrlAlgoToolkit.RevitAddins"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
[Setup]
|
|||
|
|
; 注意:AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
|
|||
|
|
; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。)
|
|||
|
|
AppId={{5DBE922F-3B20-419A-9E0E-A1A60A6554D0}
|
|||
|
|
; 程序名称
|
|||
|
|
AppName={#MyAppName}
|
|||
|
|
; 版本
|
|||
|
|
AppVersion={#MyAppVersion}
|
|||
|
|
; AppVerName={#MyAppName} {#MyAppVersion}
|
|||
|
|
AppPublisher={#MyAppPublisher}
|
|||
|
|
AppPublisherURL={#MyAppURL}
|
|||
|
|
AppSupportURL={#MyAppURL}
|
|||
|
|
AppUpdatesURL={#MyAppURL}
|
|||
|
|
;控制面板显示的名称
|
|||
|
|
UninstallDisplayName={#MyAppName}
|
|||
|
|
;安装包构建模型
|
|||
|
|
ArchitecturesInstallIn64BitMode=x64os
|
|||
|
|
;管理员权限
|
|||
|
|
PrivilegesRequired=admin
|
|||
|
|
; 是否创建应用程序目录
|
|||
|
|
CreateAppDir=no
|
|||
|
|
; 许可证文件路径
|
|||
|
|
;LicenseFile=.\bin\Release\2018\license.txt
|
|||
|
|
; 安装前显示的信息文件路径
|
|||
|
|
;InfoBeforeFile=.\bin\Release\2018\Readme.txt
|
|||
|
|
; 安装后显示的信息文件路径
|
|||
|
|
;InfoAfterFile=.\bin\Release\2018\Readme.txt
|
|||
|
|
; 取消对以下行的注释以在非管理安装模式下运行(仅针对当前用户进行安装)。
|
|||
|
|
; PrivilegesRequired=lowest
|
|||
|
|
; exe输出目录
|
|||
|
|
OutputDir=..\Setup
|
|||
|
|
; 输出文件名
|
|||
|
|
OutputBaseFilename={#MyAppName}{#MyAppVersion}
|
|||
|
|
; 密码
|
|||
|
|
;Password=SZMEDI
|
|||
|
|
; 是否加密
|
|||
|
|
|
|||
|
|
;Encryption=yes
|
|||
|
|
; 压缩方式
|
|||
|
|
Compression=lzma
|
|||
|
|
;Compression=zip
|
|||
|
|
; 是否使用固体压缩
|
|||
|
|
SolidCompression=yes
|
|||
|
|
; 向导样式
|
|||
|
|
WizardStyle=modern
|
|||
|
|
|
|||
|
|
[Files]
|
|||
|
|
; 源文件路径和目标目录
|
|||
|
|
Source: "..\bin\Release\2018\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\ShrlAlgoToolkit.RevitAddins.bundle\Contents\2018"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|||
|
|
; Source: "I:\04 程序开发\Revit Dev\Szmedi.RvKit\bin\Release\2019\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\ShrlAlgoToolkit.RevitAddins.bundle\Contents\2019"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|||
|
|
Source: "..\bin\Release\2020\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\ShrlAlgoToolkit.RevitAddins.bundle\Contents\2020"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|||
|
|
Source: "..\bin\ShrlAlgoToolkit.RevitAddins.bundle\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\ShrlAlgoToolkit.RevitAddins.bundle"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|||
|
|
; 注意:不要在任何共享系统文件上使用 "Flags: ignoreversion"
|
|||
|
|
|
|||
|
|
[Code]
|
|||
|
|
[Code]
|
|||
|
|
const
|
|||
|
|
AddinFileName = 'ShrlAlgoToolkit.RevitAddins.addin';
|
|||
|
|
|
|||
|
|
// 日志函数,用于调试
|
|||
|
|
procedure Log(const Msg: string);
|
|||
|
|
begin
|
|||
|
|
MsgBox(Msg, mbInformation, MB_OK);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// 检查目录是否存在,如果不存在则创建
|
|||
|
|
procedure CreateDirectoryIfNotExists(const Dir: string);
|
|||
|
|
begin
|
|||
|
|
if not DirExists(Dir) then
|
|||
|
|
begin
|
|||
|
|
if not CreateDir(Dir) then
|
|||
|
|
begin
|
|||
|
|
Log('目录创建失败: ' + Dir);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
Log('目录创建成功: ' + Dir);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// 检查文件是否可写
|
|||
|
|
function IsFileWritable(const FileName: string): Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
if FileExists(FileName) then
|
|||
|
|
begin
|
|||
|
|
// 尝试写入文件
|
|||
|
|
SaveStringToFile(FileName, 'test', False);
|
|||
|
|
Result := True;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
// 文件不存在,可以创建
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
except
|
|||
|
|
Log('文件不可写: ' + FileName);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// 覆写或创建 .addin 文件
|
|||
|
|
procedure ReplaceAddinFileContentForVersion(Version: String);
|
|||
|
|
var
|
|||
|
|
AddinFile: TStringList;
|
|||
|
|
FullPath: string;
|
|||
|
|
DirPath: string;
|
|||
|
|
begin
|
|||
|
|
FullPath := ExpandConstant('{commonappdata}\Autodesk\ApplicationPlugins\ShrlAlgoToolkit.RevitAddins.bundle\Contents\' + Version + '\' + AddinFileName);
|
|||
|
|
//Log('addin文件路径: ' + FullPath);
|
|||
|
|
|
|||
|
|
// 检查目录是否存在,如果不存在则创建
|
|||
|
|
DirPath := ExtractFilePath(FullPath);
|
|||
|
|
CreateDirectoryIfNotExists(DirPath);
|
|||
|
|
|
|||
|
|
// 检查文件是否可写
|
|||
|
|
if not IsFileWritable(FullPath) then
|
|||
|
|
begin
|
|||
|
|
Log('文件不可写: ' + FullPath);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// 创建并写入文件内容
|
|||
|
|
AddinFile := TStringList.Create;
|
|||
|
|
try
|
|||
|
|
AddinFile.Add('<?xml version="1.0" encoding="utf-8" standalone="no"?>');
|
|||
|
|
AddinFile.Add('<RevitAddIns>');
|
|||
|
|
AddinFile.Add(' <AddIn Type="Application">');
|
|||
|
|
AddinFile.Add(' <Name>{#MyAppName}</Name>');
|
|||
|
|
AddinFile.Add(' <Assembly>{#MyDllName}.dll</Assembly>');
|
|||
|
|
AddinFile.Add(' <AddInId>9BD39EB5-442A-49FD-999F-F4E0C4AC6643</AddInId>');
|
|||
|
|
AddinFile.Add(' <FullClassName>{#MyDllName}.UIRibbon.RvApp</FullClassName>');
|
|||
|
|
AddinFile.Add(' <VendorId>{#MyAppPublisher}</VendorId>');
|
|||
|
|
AddinFile.Add(' <VendorDescription>{#MyAppPublisher},{#MyAppURL}</VendorDescription>');
|
|||
|
|
AddinFile.Add(' </AddIn>');
|
|||
|
|
AddinFile.Add('</RevitAddIns>');
|
|||
|
|
|
|||
|
|
//AddinFile.SaveToFile(FullPath);
|
|||
|
|
// 将 TStringList 的内容转换为 UTF-8 编码的 AnsiString,并覆盖写入文件
|
|||
|
|
// 参数说明:文件名, 内容, 是否追加(False表示覆盖)
|
|||
|
|
SaveStringToFile(FullPath,UTF8Encode(AddinFile.Text), False);
|
|||
|
|
//Log('文件成功写入: ' + FullPath);
|
|||
|
|
except
|
|||
|
|
Log('文件写入失败: ' + FullPath + ' - ' + GetExceptionMessage);
|
|||
|
|
finally
|
|||
|
|
AddinFile.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// 在安装完成后调用
|
|||
|
|
procedure CurStepChanged(CurStep: TSetupStep);
|
|||
|
|
var
|
|||
|
|
RevitVersions: TArrayOfString; // 动态数组
|
|||
|
|
i: Integer;
|
|||
|
|
begin
|
|||
|
|
if CurStep = ssPostInstall then
|
|||
|
|
begin
|
|||
|
|
// 初始化 Revit 版本数组
|
|||
|
|
SetArrayLength(RevitVersions, 2); // 设置数组长度
|
|||
|
|
RevitVersions[0] := '2018';
|
|||
|
|
//RevitVersions[1] := '2019';
|
|||
|
|
RevitVersions[1] := '2020';
|
|||
|
|
//RevitVersions[3] := '2021';
|
|||
|
|
|
|||
|
|
// 遍历每个版本并处理
|
|||
|
|
for i := 0 to GetArrayLength(RevitVersions) - 1 do
|
|||
|
|
begin
|
|||
|
|
ReplaceAddinFileContentForVersion(RevitVersions[i]);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|