Пример #1
0
 /// <summary>
 /// Increments the use count and sets the last used date if the Module installer was installed.
 /// </summary>
 public static void Use()
 {
     // Enumerate all clients for the primary component if installed.
     ComponentInstallation comp = new ComponentInstallation(ModuleId);
     foreach (ProductInstallation product in comp.ClientProducts)
     {
         // If the feature is installed locally for this client, increment usage.
         FeatureInstallation feature = new FeatureInstallation(FeatureName, product.ProductCode);
         if (feature.State == InstallState.Local)
         {
             Installer.UseFeature(product.ProductCode, FeatureName, InstallMode.NoDetection);
         }
     }
 }
Пример #2
0
        public static bool IsFeatureAdvertised(string msiPath, string featureName)
        {
            string productCode = GetMSIProductCode(msiPath);

            FeatureInstallation feature = new FeatureInstallation(featureName, productCode);
            return feature.State == InstallState.Advertised;
        }
Пример #3
0
        public void InstallAdvertisedFeaturesThroughPipeline()
        {
            using (var p = CreatePipeline(@"install-msiproduct example.msi ADVERTISE=ALL TARGETDIR=`""$TestRunDirectory`"""))
            {
                var output = p.Invoke();
                Assert.AreEqual(0, output.Count);
                Assert.AreEqual(0, p.Error.Count);

                var feature = new FeatureInstallation("TEST", ExampleProductCode);
                Assert.AreEqual<InstallState>(InstallState.Advertised, feature.State);
            }

            // Need to pass the target directory since we're not rooted under well-known folders.
            var command = string.Format(@"get-msiproductinfo '{0}' | install-msiadvertisedfeature TEST -force -properties TARGETDIR=`""$TestRunDirectory`""", ExampleProductCode);
            using (var p = CreatePipeline(command))
            {
                var output = p.Invoke();
                Assert.AreEqual(0, output.Count);
                Assert.AreEqual(0, p.Error.Count);

                var feature = new FeatureInstallation("TEST", ExampleProductCode);
                Assert.AreEqual<InstallState>(InstallState.Local, feature.State);
            }

            using (var p = CreatePipeline(@"uninstall-msiproduct example.msi"))
            {
                var output = p.Invoke();
                Assert.AreEqual(0, output.Count);
                Assert.AreEqual(0, p.Error.Count);
            }
        }
Пример #4
0
 /// <summary>
 /// Enumerates the selected features and write them to the pipeline.
 /// </summary>
 protected override void ProcessRecord()
 {
     if (this.ParameterSetName == ParameterSet.Product)
     {
         // Enumerate the features of each product.
         foreach (ProductInstallation product in this.Product)
         {
             foreach (FeatureInstallation feature in product.Features)
             {
                 this.WriteFeature(feature);
             }
         }
     }
     else if (this.ParameterSetName == ParameterSet.Feature)
     {
         // Enumerate all the features of a specific product.
         foreach (string featureName in this.FeatureName)
         {
             FeatureInstallation feature = new FeatureInstallation(featureName, this.ProductCode);
             this.WriteFeature(feature);
         }
     }
 }
Пример #5
0
 /// <summary>
 /// Writes the feature to the pipeline.
 /// </summary>
 /// <param name="feature">The <see cref="FeatureInstallation"/> to write to the pipeline.</param>
 private void WriteFeature(FeatureInstallation feature)
 {
     PSObject obj = PSObject.AsPSObject(feature);
     this.WriteObject(obj);
 }
 public FeatureInstallationWrap(FeatureInstallation underlyaingObject)
 {
     _underlyaingObject = underlyaingObject;
 }