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); } }
public static bool IsFeatureAdvertised(string msiPath, string featureName) { string productCode = GetMSIProductCode(msiPath); FeatureInstallation feature = new FeatureInstallation(featureName, productCode); return(feature.State == InstallState.Advertised); }
public void UseTest() { using (OverrideRegistry()) { // Set initial usage data. Module.Use(); // Initial use should be empty (null). var feature = new FeatureInstallation("Module", "{B4EA7821-1AC1-41B5-8021-A2FC77D1B7B7}"); Assert.IsNotNull(feature.Usage); Assert.AreEqual <int>(1, feature.Usage.UseCount); } }
/// <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); } } }
/// <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); } } }
/// <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); }
private static void InitializeFeatureProperty(Session session, FeatureInstallation feature) { session["FEATURE." + feature.FeatureName.ToUpperInvariant()] = feature.State == InstallState.Local ? "1" : null; }
public FeatureInstallationWrap(FeatureInstallation underlyaingObject) { _underlyaingObject = underlyaingObject; }