75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
|
|
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"]; //<2F><>װ·<D7B0><C2B7>,<2C><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
|
var sourceDir = session["SourceDir"]; //<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ѹ·<D1B9><C2B7>
|
|||
|
|
var programFiles64Folder = session["ProgramFiles64Folder"]; //64λ<34><CEBB>װ·<D7B0><C2B7><EFBFBD><EFBFBD>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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|