添加项目文件。
This commit is contained in:
74
Sai.AddInDeployer/CustomAction.cs
Normal file
74
Sai.AddInDeployer/CustomAction.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user