/// <summary> /// Gets whether the product defined by the package <paramref name="path"/> is installed. /// </summary> /// <param name="path">The path to the package to test.</param> /// <returns>True if the package is installed; otherwise, false.</returns> public static bool IsPackageInstalled(string path) { string productCode; if (!PathsToProductCodes.TryGetValue(path, out productCode)) { productCode = MsiUtils.GetMSIProductCode(path); PathsToProductCodes.Add(path, productCode); } return(MsiUtils.IsProductInstalled(productCode)); }
public void DependencyExtension_UninstallDependencyOverrideSpecific() { string packageA = BuildPackage("A", null); string packageB = BuildPackage("B", null); MSIExec.InstallProduct(packageA, MSIExec.MSIExecReturnCode.SUCCESS); MSIExec.InstallProduct(packageB, MSIExec.MSIExecReturnCode.SUCCESS); // Now attempt the uninstall of dependency package A. string productCode = MsiUtils.GetMSIProductCode(packageB); string ignoreDependencies = String.Concat("IGNOREDEPENDENCIES=", productCode); UninstallProductWithProperties(packageA, MSIExec.MSIExecReturnCode.SUCCESS, ignoreDependencies); MSIExec.UninstallProduct(packageB, MSIExec.MSIExecReturnCode.SUCCESS); }
public void Burn_ValidateMultipleSourcePaths() { // Build the package. string packageA = this.GetPackageA().Output; string packageA_Directory = Path.GetDirectoryName(packageA); string packageA_ProductCode = MsiUtils.GetMSIProductCode(packageA); // Build the bundle. string bundleA = this.GetBundleA().Output; // Install the bundle. BundleInstaller installerA = new BundleInstaller(this, bundleA).Install(); Assert.True(MsiVerifier.IsPackageInstalled(packageA)); // Copy the package using the bundle package name. ProductInstallation product = new ProductInstallation(packageA_ProductCode, null, UserContexts.Machine); string packageA_Copy = Path.Combine(packageA_Directory, product.AdvertisedPackageName); File.Copy(packageA, packageA_Copy); this.TestArtifacts.Add(new FileInfo(packageA_Copy)); // Repair and recache the MSI. MSIExec.InstallProduct(packageA_Copy, MSIExec.MSIExecReturnCode.SUCCESS, "REINSTALL=ALL REINSTALLMODE=vomus"); Assert.True(MsiVerifier.IsPackageInstalled(packageA)); // Check that the source contains both the original and burn cached paths. SourceList sources = product.SourceList; Assert.Equal(2, sources.Count); // Attempt to uninstall bundleA. installerA.Uninstall(); Assert.False(MsiVerifier.IsPackageInstalled(packageA)); this.Complete(); }
/// <summary> /// Gets whether the product defined by the package <paramref name="path"/> is installed. /// </summary> /// <param name="path">The path to the package to test.</param> /// <returns>True if the package is installed; otherwise, false.</returns> private bool IsPackageInstalled(string path) { string productCode = MsiUtils.GetMSIProductCode(path); return(MsiUtils.IsProductInstalled(productCode)); }