Help‎ > ‎NvnInstaller.MsiDotNet‎ > ‎

About Features

MsiFeature is the basic class which contains all information about a feature. Installer user interface author can use the list of features to selectively install/uninstall.
  
MsiFeature properties

    Id - Unique identifier of the feature.
    Parent - Parent feature in the feature tree.
    ChildFeatures - List of child features. This can be used to used construct feature tree.
    Title - Short string of text identifying the feature. This string is listed as an item by the SelectionTree control
    Description - Longer string of text describing the feature.
    Display - Specifies whether this feature is enabled or not.
    FeatureCost - Number of bytes required for installing this feature.
    TotalCost - Number of bytes required for installing this feature. This also includes child features.
    Enabled - Only enabled features are installed Windows Installer.
    IsAlreadyInstalled - Specifies whether this feature is already installed on local system.
     
Use MsiInstaller.FeatureTree to get list of feature. This property gives only root features. Use ChildFeatures property recursively to get complete list of features.
  
For Example:

    public void LoadFeatures() {
        MsiInterface msiInterface = new MsiInterface(<msi filename>);
        List<MsiFeature> features = msiInterface.FeatureTree;
        foreach (MsiFeature feature in features) {
          LoadFeatureTree(feature, null);
        }
    }

    private void LoadFeatureTree(MsiFeature feature, TreeNode node) {
      TreeNode newNode = null;
      if (node == null) {
        newNode = tvFeatures.Nodes.Add(feature.Title);
      } else {
        newNode = node.Nodes.Add(feature.Title);
      }

      newNode.Checked = feature.IsAlreadyInstalled;

      if (feature.ChildFeatures != null) {
        foreach (MsiFeature childFeature in feature.ChildFeatures) {
          LoadFeatureTree(childFeature, newNode);
        }
      }
    }
  
Use IsAlreadyInstalled property of MsiFeature to know whether feature is already installed on local system.

How to use it for installation

1. for installation - Supply the list of features to install.
2. for uninstallation - Supply the list of features to uninstall.
3. for update - Supply separate list of features to install and uninstall.
Note: Child features are not considered. Only the features mentioned in the list is used.