static void Main(string[] args) { bool uninstall = false; foreach (string s in args) { if (s == @"/uninstall") { uninstall = true; } else if (Directory.Exists(s)) { debugPath = s; } } if (uninstall && string.IsNullOrEmpty(debugPath)) { //just use the executing assembly location var assemblyPath = Assembly.GetExecutingAssembly().Location; debugPath = Path.GetDirectoryName(assemblyPath); } var allProducts = RevitProductUtility.GetAllInstalledRevitProducts(); var prodCollection = new RevitProductCollection(allProducts.Select(x => new DynamoRevitProduct(x))); if (!prodCollection.Products.Any()) { Console.WriteLine("There were no Revit products found."); return; } var dynamos = DynamoProducts.FindDynamoInstallations(debugPath); if (!dynamos.Products.Any()) { Console.WriteLine("No Dynamo installation found at {0}.", debugPath); DeleteExistingAddins(prodCollection); return; } DeleteExistingAddins(prodCollection); if (uninstall) { GenerateAddins(prodCollection, debugPath); } else { GenerateAddins(prodCollection); } }
/// <summary> /// Finds all Dynamo installations on the system by looking at registry /// and install directories, and ensuring that it contains DynamoCore. /// </summary> /// <returns>List of IDynamoInstall</returns> public static IEnumerable <IDynamoInstall> FindDynamoInstalls(string debugPath) { var dynamos = DynamoProducts.FindDynamoInstallations(debugPath); foreach (IInstalledProduct product in dynamos.Products) { string[] files = Directory.GetFiles(product.InstallLocation, "DynamoRevit*.dll"); string[] dirs = Directory.GetDirectories(product.InstallLocation, "Revit*"); if (dirs.Any() || files.Any()) { yield return(new DynamoInstall(product.InstallLocation)); } } }
public void DynamoProductsOverrideWithDebugPath() { const string myPath = @"C:\MyXYZ\"; const string dyn063 = @"C:\Autodesk\Dynamo\Core"; var products = new Dictionary <string, Tuple <int, int, int, int> > { { "A", Tuple.Create(0, 1, 2, 3) }, { "B", Tuple.Create(0, 1, 3, 4) }, { "C", Tuple.Create(0, 8, 2, 4) }, { "D", Tuple.Create(1, 0, 3, 4) }, { "E", null } }; var locations = new Dictionary <string, Tuple <int, int, int, int> > { { myPath, Tuple.Create(0, 8, 2, 3) }, { dyn063, Tuple.Create(0, 6, 3, 4242) }, }; var lookUp = SetUpProductLookUp(products, locations); var p = DynamoProducts.FindDynamoInstallations(myPath, lookUp); Assert.AreEqual("D", p.GetLatestProduct().ProductName); Assert.AreEqual("1.0.3.4", p.GetLatestProduct().VersionString); Assert.AreEqual(5, p.Products.Count()); //Product C is dropped because myPath with same version is provided. Assert.IsFalse(p.Products.Any(x => x.ProductName == "C")); //Find product name starting with "XYZ", name given for lookup var prods = p.Products.Where(x => x.ProductName.StartsWith("XYZ")); var prod063 = prods.First(); var prod082 = prods.Last(); Assert.AreEqual(2, prods.Count()); Assert.AreEqual(dyn063, prod063.InstallLocation); Assert.AreEqual("XYZ 0.6", prod063.ProductName); Assert.AreEqual("0.6.3.4242", prod063.VersionString); Assert.AreEqual(myPath, prod082.InstallLocation); Assert.AreEqual("XYZ 0.8", prod082.ProductName); Assert.AreEqual("0.8.2.3", prod082.VersionString); }