private string GetFeatureDirectory(MSIFeature Feature) { if (Feature.directory != null) { return(Feature.directory); } else { IEnumerator featComps = featureComponents.Keys.GetEnumerator(); while (featComps.MoveNext()) { string componentName = (string)featComps.Current; string featureName = (string)featureComponents[componentName]; if (featureName == Feature.name) { return((string)components[componentName]); } } throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Feature '{0}' needs to be assigned a component or directory.", Feature.name), Location); } }
/// <summary> /// Adds a feature record to the Features table. /// </summary> /// <param name="featureTable">The MSI database Feature table.</param> /// <param name="conditionTable">The MSI database Condition table.</param> /// <param name="ParentFeature">The name of this feature's parent.</param> /// <param name="database">The MSI database.</param> /// <param name="Feature">This Feature's Schema element.</param> /// <param name="Depth">The tree depth of this feature.</param> /// <param name="Order">The tree order of this feature.</param> private void AddFeature(InstallerTable featureTable, InstallerTable conditionTable, string ParentFeature, InstallerDatabase database, MSIFeature Feature, int Depth, int Order) { const int TypicalInstallLevel = 3; const int NonTypicalInstallLevel = 4; int featureInstallLevel = Feature.typical ? TypicalInstallLevel : NonTypicalInstallLevel; // Insert the Feature featureTable.InsertRecord(Feature.name, ParentFeature, Feature.title, Feature.description, Feature.display, featureInstallLevel, GetFeatureDirectory(Feature), Feature.attr); Log(Level.Verbose, "\t" + Feature.name); AddFeatureConditions(Feature, conditionTable); if (Feature.feature != null) { foreach (MSIFeature childFeature in Feature.feature) { int newDepth = Depth + 1; int newOrder = 1; AddFeature(featureTable, conditionTable, Feature.name, database, childFeature, newDepth, newOrder); newOrder++; } } }
private void AddFeatureConditions(MSIFeature Feature, InstallerTable conditionTable) { if (Feature.conditions != null) { Log(Level.Verbose, "\t\tAdding Feature Conditions..."); foreach (MSIFeatureCondition featureCondition in Feature.conditions) { try { // Insert the feature's condition conditionTable.InsertRecord(Feature.name, featureCondition.level, featureCondition.expression); } catch (Exception ex) { Log(Level.Info, "Error adding feature condition: " + ex.Message); } } Log(Level.Verbose, "Done"); } }
private string GetFeatureDirectory(MSIFeature Feature) { if (Feature.directory != null) { return Feature.directory; } else { IEnumerator featComps = featureComponents.Keys.GetEnumerator(); while (featComps.MoveNext()) { string componentName = (string)featComps.Current; string featureName = (string)featureComponents[componentName]; if (featureName == Feature.name) { return (string)components[componentName]; } } throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Feature '{0}' needs to be assigned a component or directory.", Feature.name), Location); } }