Skip to content

Commit

Permalink
Support Installer version from Revit 2014 to 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Jan 21, 2022
1 parent e898968 commit 366c577
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
25 changes: 25 additions & 0 deletions Installer/BuildVersions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Installer
{
public class BuildVersions
{
public enum RevitVersion
{
Revit2014 = 2014,
Revit2015 = 2015,
Revit2016 = 2016,
Revit2017 = 2017,
Revit2018 = 2018,
Revit2019 = 2019,
Revit2020 = 2020,
Revit2021 = 2021,
Revit2022 = 2022,
Revit2023 = 2023,
}
}
}
31 changes: 20 additions & 11 deletions Installer/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Installer;
using WixSharp;
using WixSharp.CommonTasks;
using WixSharp.Controls;
Expand All @@ -17,13 +18,14 @@

var version = GetAssemblyVersion(out var dllVersion);
var fileName = new StringBuilder().Append(outputName).Append("-").Append(dllVersion);

var project = new Project
{
Name = projectName,
OutDir = outputDir,
Platform = Platform.x64,
Description = "Project Support Developer Work With Revit API",
UI = WUI.WixUI_InstallDir,
ReinstallMode = "e",
Version = new Version(version),
OutFileName = fileName.ToString(),
InstallScope = InstallScope.perUser,
Expand All @@ -35,6 +37,7 @@
{
Manufacturer = "Autodesk",
HelpLink = "https://github.com/chuongmep/RevitAddInManager/issues",
Comments = "Project Support Developer With Revit API",
ProductIcon = @"Installer\Resources\Icons\ShellIcon.ico"
},
Dirs = new Dir[]
Expand All @@ -54,16 +57,21 @@ WixEntity[] GenerateWixEntities()

foreach (var directory in args)
{
var directoryInfo = new DirectoryInfo(directory);
var fileVersion = versionRegex.Match(directoryInfo.Name).Value;
var files = new Files($@"{directory}\*.*");
if (versionStorages.ContainsKey(fileVersion))
versionStorages[fileVersion].Add(files);
else
versionStorages.Add(fileVersion, new List<WixEntity> {files});
Console.WriteLine($"Find dll in directory: {directory}");
//DirectoryInfo directoryInfo = new DirectoryInfo(directory);
//string fileVersion = versionRegex.Match(directoryInfo.Name).Value;
Files files = new Files($@"{directory}\*.*");
foreach (int version in Enum.GetValues(typeof(BuildVersions.RevitVersion)))
{
Console.WriteLine($"Start addd file to folder {directory}/{version}");
if (versionStorages.ContainsKey(version.ToString()))
versionStorages[version.ToString()].Add(files);
else
versionStorages.Add(version.ToString(), new List<WixEntity> { files });
Console.WriteLine($"Added '{version}' version files: ");
}

var assemblies = Directory.GetFiles(directory, "*", SearchOption.AllDirectories);
Console.WriteLine($"Added '{fileVersion}' version files: ");
foreach (var assembly in assemblies) Console.WriteLine($"'{assembly}'");
}

Expand All @@ -72,9 +80,10 @@ WixEntity[] GenerateWixEntities()

string GetAssemblyVersion(out string originalVersion)
{
string AssemblyName = @"AddinManager.dll";
foreach (var directory in args)
{
var assemblies = Directory.GetFiles(directory, @"AddinManager.dll", SearchOption.AllDirectories);
var assemblies = Directory.GetFiles(directory,AssemblyName, SearchOption.AllDirectories);
if (assemblies.Length == 0) continue;
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblies[0]);
var versionGroups = fileVersionInfo.ProductVersion.Split('.');
Expand All @@ -86,5 +95,5 @@ string GetAssemblyVersion(out string originalVersion)
return wixVersion;
}

throw new Exception($"Cant find AddinManager.dll file");
throw new Exception($"Cant find {AssemblyName} file");
}
15 changes: 8 additions & 7 deletions Readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Some feature include:
- [x] AddInManagerFaceless
- [x] AddInManagerReadOnly
- [x] Application

### Startup

![](pic/_Image_fd36c982-f8dd-4961-af2c-61301ee6eb4a.png)
Expand All @@ -60,7 +61,7 @@ Some feature include:

## Installation

TODO
Please follow last release at section [Release](https://github.com/chuongmep/RevitAddInManager/releases/latest)

---

Expand Down Expand Up @@ -116,14 +117,14 @@ Thanks to [JetBrains](https://www.jetbrains.com/) for providing licenses for [Ri

I suggest you some of these projects, hope you will like it.

[RevitLookup](https://github.com/jeremytammik/RevitLookup)
- [RevitLookup](https://github.com/jeremytammik/RevitLookup)

[RevitLookupWpf](https://github.com/chuongmep/RevitLookupWpf)
- [RevitLookupWpf](https://github.com/chuongmep/RevitLookupWpf)

[Revit.ScriptCS](https://github.com/sridharbaldava/Revit.ScriptCS)
- [Revit.ScriptCS](https://github.com/sridharbaldava/Revit.ScriptCS)

[Revit.TestRunner](https://github.com/geberit/Revit.TestRunner)
- [Revit.TestRunner](https://github.com/geberit/Revit.TestRunner)

[Revit.Async](https://github.com/KennanChan/Revit.Async)
- [Revit.Async](https://github.com/KennanChan/Revit.Async)

[pyRevit](https://github.com/eirannejad/pyRevit)
- [pyRevit](https://github.com/eirannejad/pyRevit)

0 comments on commit 366c577

Please sign in to comment.