添加项目文件。

This commit is contained in:
GG Z
2024-09-22 11:05:41 +08:00
parent fb5d55723a
commit 49ceaae6a8
764 changed files with 78850 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
namespace Sai.AddInDeployer
{
public class CustomActions
{
[CustomAction]
public static ActionResult Installer(Session session)
{
session.Log("Begin Installer");
//MessageBox.Show("rundll32.exe");
var manufacturer = session["Manufacturer"];
var productName = session["ProductName"];
var appDir = session["APPDIR"]; //安装路径,根据用户选择
var sourceDir = session["SourceDir"]; //安装包解压路径
var programFiles64Folder = session["ProgramFiles64Folder"]; //64位安装路径C:\ProgramFiles
var commonAppDataFolder = session["CommonAppDataFolder"]; //C:\ProgramData
var addInFilePath = $"{commonAppDataFolder}\\Autodesk\\{Contraints.BundleFolderName}\\Contents";
//List<RevitProduct> revitProductsInstalled = RevitProductUtility.GetAllInstalledRevitProducts();
//foreach (var product in revitProductsInstalled)
//{
//}
var fileInfos = new List<FileInfo>();
var dir = Directory.CreateDirectory(appDir);
var sb = new StringBuilder();
foreach (var fileInfo in dir.GetFiles("*", SearchOption.AllDirectories))
{
//var match = Regex.Match(filePath.Name, @"Sai\.RvKit\.dll$");
//if (!match.Success)
//{
// match = Regex.Match(filePath.Name, @"(\d\d\d\d)\.exe$");
// if (!match.Success)
// continue;
//}
//if (match.Success)
//{
// dlls.Add(filePath.FullName);
//}
if (fileInfo.Name == Contraints.DllFileName)
{
fileInfos.Add(fileInfo);
}
}
foreach (var dllPath in fileInfos)
{
var versionNum = dllPath.Directory?.Name;
var manager = new AddInManager(versionNum, Contraints.AddInFileName);
foreach (var fullName in Contraints.RibbonFullClassNames)
{
manager.CreateApplication(Contraints.AddInAppName, dllPath.FullName, fullName);
}
manager.Uninstall();
manager.Install();
}
return ActionResult.Success;
}
[CustomAction]
public static ActionResult Uninstaller(Session session)
{
session.Log("Begin Uninstaller");
var commonAppDataFolder = session["CommonAppDataFolder"];
var addInFilePath = $"{commonAppDataFolder}\\Autodesk\\{Contraints.BundleFolderName}";
Directory.Delete(addInFilePath, true);
return ActionResult.Success;
}
}
}