コード例 #1
0
        public void Burn_UninstallAddonBundle()
        {
            const string expectedVersion = "1.0.0.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);

            // Build the bundles.
            string bundleA1 = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleA2 = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleF = new BundleBuilder(this, "BundleF")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the base bundle and make sure all packages are installed.
            BundleInstaller installerF = new BundleInstaller(this, bundleF).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));

            // Install an addon bundle and make sure all packages are installed.
            BundleInstaller installerA1 = new BundleInstaller(this, bundleA1).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion, actualVersion);
            }

            // Install a second addon bundle and make sure all packages are installed.
            BundleInstaller installerA2 = new BundleInstaller(this, bundleA2).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion, actualVersion);
            }

            // Uninstall the base bundle and make sure all packages are uninstalled.
            installerF.Uninstall();
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            Assert.IsNull(this.GetTestRegistryRoot());

            this.CleanTestArtifacts = true;
        }
コード例 #2
0
        public void Burn_UninstallUpgradedBundle()
        {
            const string expectedVersion1 = "1.0.0.0";
            const string expectedVersion2 = "1.0.1.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageA1 = new PackageBuilder(this, "A")
            {
                Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Override the path for A to A1.
            bindPaths["packageA"] = packageA1;
            string bundleA1 = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }
            }.Build().Output;

            // Install the bundles.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();

            // Make sure the MSIs and EXE are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion1, actualVersion);
            }

            // Attempt to upgrade bundleA.
            BundleInstaller installerA1 = new BundleInstaller(this, bundleA1).Install();

            // Verify packageA1 was installed and packageA was uninstalled.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion2, actualVersion);
            }

            // Uninstall bundleA1 and verify that packageA1 is still installed.
            installerA1.Uninstall();
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));

            // Uninstall bundleB now.
            installerB.Uninstall();

            // BUG: BundleB does not know about PackageA1 (A,v2), so remove it explicitly (SFBUG:3307315).
            MSIExec.UninstallProduct(packageA1, MSIExec.MSIExecReturnCode.SUCCESS);

            // Make sure the MSIs are not installed.
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsNull(this.GetTestRegistryRoot());

            this.CleanTestArtifacts = true;
        }
コード例 #3
0
        public void Burn_InstallUpgradeSlipstreamBundle()
        {
            const string expectedVersion1 = "1.0.0.0";
            const string expectedVersion2 = "1.0.1.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageA1 = new PackageBuilder(this, "A")
            {
                Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string patchA = new PatchBuilder(this, "PatchA")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }, TargetPath = packageA, UpgradePath = packageA1
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("patchA", patchA);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleC = new BundleBuilder(this, "BundleC")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }
            }.Build().Output;

            // Install the base bundle and make sure it's installed.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion1, actualVersion);
            }

            // Install the upgrade bundle with a slipstreamed patch and make sure the patch is installed.
            // SFBUG:3387046 - Uninstalling bundle registers a dependency on a package
            BundleInstaller installerC = new BundleInstaller(this, bundleC).Install();

            Assert.IsTrue(MsiUtils.IsPatchInstalled(patchA));

            // BundleC doesn't carry the EXE, so make sure it's removed.
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                Assert.IsNull(root.GetValue("Version"));
            }

            // Repair the upgrade bundle to make sure it does not prompt for source.
            // SFBUG:3386927 - MSIs get removed from cache during upgrade
            installerC.Repair();

            // Uninstall the slipstream bundle and make sure both packages are uninstalled.
            installerC.Uninstall();
            Assert.IsFalse(MsiUtils.IsPatchInstalled(patchA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));

            this.CleanTestArtifacts = true;
        }
コード例 #4
0
        public void Burn_InstallUpdatedBundleOptionalUpdateRegistration()
        {
            string v2Version = "2.0.0.0";

            // Build the packages.
            string packageAv1 = new PackageBuilder(this, "A").Build().Output;
            string packageAv2 = new PackageBuilder(this, "A")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", v2Version }
                }
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPathsv1 = new Dictionary <string, string>()
            {
                { "packageA", packageAv1 }
            };
            Dictionary <string, string> bindPathsv2 = new Dictionary <string, string>()
            {
                { "packageA", packageAv2 }
            };

            // Build the bundles.
            string bundleAv1 = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPathsv1, Extensions = Extensions
            }.Build().Output;
            string bundleAv2 = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPathsv2, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", v2Version }
                }
            }.Build().Output;

            // Initialize with first bundle.
            BundleInstaller installerAv1 = new BundleInstaller(this, bundleAv1).Install();

            Assert.True(MsiVerifier.IsPackageInstalled(packageAv1));

            // Make sure the OptionalUpdateRegistration exists.
            // SOFTWARE\[Manufacturer]\Updates\[ProductFamily]\[Name]
            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft Corporation\Updates\~Burn_InstallUpdatedBundleOptionalUpdateRegistration - Bundle A"))
            {
                Assert.Equal("Y", key.GetValue("ThisVersionInstalled"));
                Assert.Equal("1.0.0.0", key.GetValue("PackageVersion"));
            }

            // Install second bundle which will major upgrade away v1.
            BundleInstaller installerAv2 = new BundleInstaller(this, bundleAv2).Install();

            Assert.False(MsiVerifier.IsPackageInstalled(packageAv1));
            Assert.True(MsiVerifier.IsPackageInstalled(packageAv2));

            // Make sure the OptionalUpdateRegistration exists.
            // SOFTWARE\[Manufacturer]\Updates\[ProductFamily]\[Name]
            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft Corporation\Updates\~Burn_InstallUpdatedBundleOptionalUpdateRegistration - Bundle A"))
            {
                Assert.Equal("Y", key.GetValue("ThisVersionInstalled"));
                Assert.Equal("2.0.0.0", key.GetValue("PackageVersion"));
            }

            // Uninstall the second bundle and everything should be gone.
            installerAv2.Uninstall();
            Assert.False(MsiVerifier.IsPackageInstalled(packageAv1));
            Assert.False(MsiVerifier.IsPackageInstalled(packageAv2));

            // Make sure the key is removed.
            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft Corporation\Updates\~Burn_InstallUpdatedBundleOptionalUpdateRegistration - Bundle A"))
            {
                Assert.Null(key);
            }
        }
コード例 #5
0
        public void Burn_UpdateInstalledPerUserBundleUpdateServerUpdateFeed()
        {
            // Build the packages.
            string packageB1 = this.GetPackageB().Output;
            string packageB2 = this.GetPackageBv2().Output;

            // Build the bundles.
            string bundleB1 = this.GetBundleB().Output;
            string bundleB2 = this.GetBundleBv2().Output;

            // Install the v1 bundle.
            BundleInstaller installerB1 = new BundleInstaller(this, bundleB1).Install();

            // Test that v1 was correctly installed.
            Assert.True(MsiVerifier.IsPackageInstalled(packageB1));
            Assert.False(MsiVerifier.IsPackageInstalled(packageB2));

            HostConfiguration hostConfigs = new HostConfiguration()
            {
                UrlReservations = new UrlReservations()
                {
                    CreateAutomatically = true
                },
                AllowChunkedEncoding = false // https://github.com/NancyFx/Nancy/issues/1337
            };

            string rootDirectory = FileUtilities.GetUniqueFileName();

            this.TestArtifacts.Add(new DirectoryInfo(rootDirectory));

            Directory.CreateDirectory(Path.Combine(rootDirectory, "1.0"));
            Directory.CreateDirectory(Path.Combine(rootDirectory, "2.0"));

            // Copy v1.0 artifacts to the TestDataDirectory
            File.Copy(bundleB1, Path.Combine(rootDirectory, "1.0", Path.GetFileName(bundleB1)), true);
            File.Copy(Path.Combine(this.TestContext.TestDataDirectory, "FeedBv1.0.xml"), Path.Combine(rootDirectory, "1.0", "FeedBv1.0.xml"), true);

            // Copy v1.1 artifacts to the TestDataDirectory
            File.Copy(bundleB2, Path.Combine(rootDirectory, "2.0", Path.GetFileName(bundleB2)), true);
            File.Copy(Path.Combine(this.TestContext.TestDataDirectory, "FeedBv2.0.xml"), Path.Combine(rootDirectory, "2.0", "FeedBv2.0.xml"), true);
            RootPathProvider.RootPath = rootDirectory;

            // Verify bundle asking for update and getting an updated feed updates
            FeedModule.FeedBehavior = FeedModule.UpdateFeedBehavior.Version2;
            using (NancyHost nancyHost = new NancyHost(this.UpdateUri, new ApplicationBootstrapper(), hostConfigs)
            {
            })
            {
                nancyHost.Start();

                // Run the v1 bundle providing an update bundle.
                installerB1.Modify(arguments: "-checkupdate");

                // The modify -> update is asynchronous, so we need to wait until the real BundleB is done
                System.Diagnostics.Process[] childBundles = System.Diagnostics.Process.GetProcessesByName(Path.GetFileNameWithoutExtension(bundleB2));
                foreach (var childBundle in childBundles)
                {
                    childBundle.WaitForExit();
                }
            }
            // Test that only v2 packages is installed.
            Assert.False(MsiVerifier.IsPackageInstalled(packageB1));
            Assert.True(MsiVerifier.IsPackageInstalled(packageB2));

            // Attempt to uninstall v2.
            BundleInstaller installerB2 = new BundleInstaller(this, bundleB2).Uninstall();

            // Test all packages are uninstalled.
            Assert.False(MsiVerifier.IsPackageInstalled(packageB1));
            Assert.False(MsiVerifier.IsPackageInstalled(packageB2));
            Assert.Null(this.GetTestRegistryRoot());

            this.Complete();
        }
コード例 #6
0
        public void Burn_ForwardCompatiblePerUserParentTwiceMajorUpgrade()
        {
            string providerId    = String.Concat("~", this.TestContext.TestName, "_BundleC");
            string parent        = "~BundleCv1";
            string parent2       = "~BundleCv1_Parent2";
            string parentSwitch  = String.Concat("-parent ", parent);
            string parent2Switch = String.Concat("-parent ", parent2);

            // Build.
            string packageC   = this.GetPackageC().Output;
            string packageCv2 = this.GetPackageCv2().Output;

            string bundleC   = this.GetBundleC().Output;
            string bundleCv2 = this.GetBundleCv2().Output;

            // Install the v1 bundle with a parent.
            BundleInstaller installerCv1 = new BundleInstaller(this, bundleC).Install(arguments: parentSwitch);

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageCv2));

            string actualProviderVersion;

            Assert.IsTrue(this.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.AreEqual("1.0.0.0", actualProviderVersion);
            Assert.IsTrue(this.DependencyDependentExists(providerId, parent));

            // Install the v1 bundle with a second parent.
            installerCv1.Install(arguments: parent2Switch);
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageCv2));

            Assert.IsTrue(this.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.AreEqual("1.0.0.0", actualProviderVersion);
            Assert.IsTrue(this.DependencyDependentExists(providerId, parent));

            // Upgrade with the v2 bundle.
            BundleInstaller installerCv2 = new BundleInstaller(this, bundleCv2).Install();

            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageCv2));

            Assert.IsTrue(this.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.AreEqual(V2, actualProviderVersion);
            Assert.IsTrue(this.DependencyDependentExists(providerId, parent));

            // Uninstall the v2 bundle and nothing should happen because there is still a parent.
            installerCv2.Uninstall();
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageCv2));

            Assert.IsTrue(this.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.AreEqual(V2, actualProviderVersion);
            Assert.IsTrue(this.DependencyDependentExists(providerId, parent));

            // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent.
            installerCv1.Uninstall(arguments: parentSwitch);
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageCv2));

            Assert.IsTrue(this.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.AreEqual(V2, actualProviderVersion);
            Assert.IsTrue(this.DependencyDependentExists(providerId, parent2));

            // Uninstall the v1 bundle with passthrough with second parent and all should be removed.
            installerCv1.Uninstall(arguments: parent2Switch);
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageCv2));

            Assert.IsFalse(this.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));

            this.CleanTestArtifacts = true;
        }
コード例 #7
0
ファイル: Burn.RelatedBundleTests.cs プロジェクト: fyisa/wix3
        public void Burn_InstallUninstallStickyPatchRelatedBundle()
        {
            const string patchVersion = "1.0.1.0";

            // Build the packages.
            string packageA1 = new PackageBuilder(this, "A").Build().Output;
            string packageA2 = new PackageBuilder(this, "A")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string packageB1 = new PackageBuilder(this, "B").Build().Output;
            string packageB2 = new PackageBuilder(this, "B")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string patchA = new PatchBuilder(this, "PatchA")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion }
                },
                TargetPaths  = new string[] { packageA1, packageB1 },
                UpgradePaths = new string[] { packageA2, packageB2 }
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA1);
            bindPaths.Add("packageB", packageB1);
            bindPaths.Add("patchA", patchA);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleD = new BundleBuilder(this, "BundleD")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion }
                }, BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the bundles.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerD = new BundleInstaller(this, bundleD).Install();

            // Make sure that bundle D detected dependent bundle A.
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerD.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Dependent, scope: PerMachine, version: 1\.0\.0\.0, operation: None"));

            // Test that packageA1 and patchA are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("A") as string;
                Assert.AreEqual(patchVersion, actualVersion);
            }

            // Install bundle B (tests sticky patching).
            BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();

            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerB.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Patch, scope: PerMachine, version: 1\.0\.1\.0, operation: Install"));
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerB.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Detect, scope: PerMachine, version: 1\.0\.0\.0, operation: None"));

            // Test that packageB and patchA are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB1));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("B") as string;
                Assert.AreEqual(patchVersion, actualVersion);
            }

            // Attempt to uninstall bundleA.
            installerA.Uninstall();

            // Test that packageA is still installed (ref-counted).
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));

            // Test that uninstalling bundle A detected bundle D (ref-counted).
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Patch, scope: PerMachine, version: 1\.0\.1\.0, operation: Remove"));
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Will not uninstall package: \{[0-9A-Za-z\-]{36}\}, found dependents: 1"));

            // Attempt to uninstall bundleB.
            installerB.Uninstall();

            // Test that all packages are uninstalled.
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB1));
            Assert.IsNull(this.GetTestRegistryRoot());

            // Test that uninstalling bundle B detected and removed bundle D (ref-counted).
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerB.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Patch, scope: PerMachine, version: 1\.0\.1\.0, operation: Remove"));

            this.CleanTestArtifacts = true;
        }
コード例 #8
0
ファイル: Burn.RelatedBundleTests.cs プロジェクト: fyisa/wix3
        public void Burn_InstallUninstallStickyAddonRelatedBundle()
        {
            // Build the packages.
            string packageA = new PackageBuilder(this, "A").Build().Output;
            string packageB = new PackageBuilder(this, "B").Build().Output;
            string packageC = new PackageBuilder(this, "C").Build().Output;
            string packageD = new PackageBuilder(this, "D").Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);
            bindPaths.Add("packageC", packageC);
            bindPaths.Add("packageD", packageD);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleC = new BundleBuilder(this, "BundleC")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the bundles.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerC = new BundleInstaller(this, bundleC).Install();

            // Make sure that bundle C detected dependent bundle A.
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerC.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Dependent, scope: PerMachine, version: 1\.0\.0\.0, operation: None"));

            // Test that packages A and C but not D are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));

            // Install bundle B (tests sticky addons).
            BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();

            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerB.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Addon, scope: PerMachine, version: 1\.0\.0\.0, operation: Install"));
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerB.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Detect, scope: PerMachine, version: 1\.0\.0\.0, operation: None"));

            // Test that all packages are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageD));

            // Attempt to uninstall bundleA.
            installerA.Uninstall();

            // Test that packageA is still installed (ref-counted).
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));

            // Test that uninstalling bundle A detected bundle C (ref-counted).
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Addon, scope: PerMachine, version: 1\.0\.0\.0, operation: Remove"));
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Will not uninstall package: \{[0-9A-Za-z\-]{36}\}, found dependents: 1"));

            // Attempt to uninstall bundleB.
            installerB.Uninstall();

            // Test that all packages are uninstalled.
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));

            // Test that uninstalling bundle B detected and removed bundle C (ref-counted).
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerB.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Addon, scope: PerMachine, version: 1\.0\.0\.0, operation: Remove"));

            this.CleanTestArtifacts = true;
        }
コード例 #9
0
ファイル: Burn.RelatedBundleTests.cs プロジェクト: fyisa/wix3
        public void Burn_InstallUninstallUpgradePatchRelatedBundleWithAddon()
        {
            const string patchVersion1 = "1.0.1.0";
            const string patchVersion2 = "1.0.2.0";

            // Build the packages.
            string packageA1 = new PackageBuilder(this, "A").Build().Output;
            string packageA2 = new PackageBuilder(this, "A")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion1 }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string packageA3 = new PackageBuilder(this, "A")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion2 }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string packageC = new PackageBuilder(this, "C").Build().Output;
            string packageD = new PackageBuilder(this, "D").Build().Output;
            string patchA1  = new PatchBuilder(this, "PatchA")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion1 }
                }, TargetPath = packageA1, UpgradePath = packageA2
            }.Build().Output;
            string patchA2 = new PatchBuilder(this, "PatchA")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion2 }
                }, TargetPath = packageA1, UpgradePath = packageA3
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA1);
            bindPaths.Add("packageC", packageC);
            bindPaths.Add("packageD", packageD);
            bindPaths.Add("patchA", patchA1);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleC = new BundleBuilder(this, "BundleC")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleD1 = new BundleBuilder(this, "BundleD")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion1 }
                }, BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Build the v2 patch bundle.
            bindPaths["patchA"] = patchA2;
            string bundleD2 = new BundleBuilder(this, "BundleD")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchVersion2 }
                }, BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the bundles.
            BundleInstaller installerA  = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerD1 = new BundleInstaller(this, bundleD1).Install();

            // Test both packages are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("A") as string;
                Assert.AreEqual(patchVersion1, actualVersion);
            }

            // Install the addon bundle.
            BundleInstaller installerC = new BundleInstaller(this, bundleC).Install();

            // Test that package C but not D is installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));

            // Install the v2 patch bundles.
            BundleInstaller installerD2 = new BundleInstaller(this, bundleD2).Install();

            // Test that all packages but D are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("A") as string;
                Assert.AreEqual(patchVersion2, actualVersion);
            }

            // Test that installing D2 upgrades D1.
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerD2.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Upgrade, scope: PerMachine, version: 1\.0\.1\.0, operation: MajorUpgrade"));

            // Attempt to uninstall bundleA.
            installerA.Uninstall();

            // Test that uninstalling bundle A detected and would remove bundles C and D.
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Addon, scope: PerMachine, version: 1\.0\.0\.0, operation: Remove"));
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Patch, scope: PerMachine, version: 1\.0\.2\.0, operation: Remove"));

            // Test all packages are uninstalled.
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));
            Assert.IsNull(this.GetTestRegistryRoot());

            this.CleanTestArtifacts = true;
        }
コード例 #10
0
ファイル: Burn.EmbeddedTests.cs プロジェクト: roni8686/wix3
        public void Burn_InstallUninstallMajorUpgrade()
        {
            string v2Version = "2.0.0.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageC = new PackageBuilder(this, "C")
            {
                Extensions = Extensions
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);
            bindPaths.Add("packageC", packageC);
            // Add the bindpath for the cab for C to enable to add it as a payload for BundleA
            bindPaths.Add("packageCcab", Path.Combine(Path.GetDirectoryName(packageC), "cab1.cab"));

            // Build the embedded bundle and the earlier version of the bundle.
            string bundleBv1 = new BundleBuilder(this, "BundleBv1")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleBv2 = new BundleBuilder(this, "BundleBv2")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", v2Version }
                }
            }.Build().Output;

            // Build the parent bundle.
            bindPaths.Add("bundleBv2", bundleBv2);
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", v2Version }
                }
            }.Build().Output;

            // Install Bv1
            BundleInstaller installerBv1 = new BundleInstaller(this, bundleBv1).Install();

            Assert.True(MsiVerifier.IsPackageInstalled(packageB));

            // Install the bundle containing the upgraded embedded bundle.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();

            Assert.False(MsiVerifier.IsPackageInstalled(packageB));
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            Assert.True(MsiVerifier.IsPackageInstalled(packageC));

            // Attempt to uninstall bundleA, which will uninstall bundleBv2 since it is a patch related bundle.
            installerA.Uninstall();
            Assert.False(MsiVerifier.IsPackageInstalled(packageA));
            Assert.False(MsiVerifier.IsPackageInstalled(packageC));

            this.Complete();
        }
        public void Burn_MajorUpgradeWithSlipstream()
        {
            const string originalVersion = "1.0.0.0";
            const string upgradeVersion  = "2.0.0.0";
            const string patchedVersion  = "2.0.1.0";

            // Build the packages.
            string originalPackageA = this.GetPackageA().Output;
            string upgradePackageA  = new PackageBuilder(this, "A")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", upgradeVersion }
                },
            }.Build().Output;
            string packageAUpdate = new PackageBuilder(this, "A")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchedVersion }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string patchA = new PatchBuilder(this, "PatchA")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", patchedVersion }
                }, TargetPaths = new string[] { upgradePackageA }, UpgradePaths = new string[] { packageAUpdate }
            }.Build().Output;

            // Create the named bind paths to the packages in the bundle.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", upgradePackageA);
            bindPaths.Add("patchA", patchA);

            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the original MSI.
            MSIExec.InstallProduct(originalPackageA, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.True(MsiVerifier.IsPackageInstalled(originalPackageA));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                // Original Product A should be present.
                string actualVersion = root.GetValue("A") as string;
                Assert.Equal(originalVersion, actualVersion);
            }

            // Now install the bundle that should upgrade the MSI and apply the patch.
            BundleInstaller install = new BundleInstaller(this, bundleA).Install();

            Assert.False(MsiVerifier.IsPackageInstalled(originalPackageA));
            Assert.True(MsiVerifier.IsPackageInstalled(upgradePackageA));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                // Product A should've slipstreamed with its patch.
                string actualVersion = root.GetValue("A") as string;
                Assert.Equal(patchedVersion, actualVersion);
            }

            install.Uninstall();

            Assert.True(null == this.GetTestRegistryRoot(), "Test registry key should have been removed during uninstall.");

            this.Complete();
        }
コード例 #12
0
        public void Burn_MixedScopeUpgradedBundle()
        {
            const string upgradeVersion = "1.0.1.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageD1 = new PackageBuilder(this, "D")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageD2 = new PackageBuilder(this, "D")
            {
                Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", upgradeVersion }
                }
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageD", packageD1);

            // Build the base bundle.
            string bundleH1 = new BundleBuilder(this, "BundleH")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Override the path for D1 to D2 and build the upgrade bundle.
            bindPaths["packageD"] = packageD2;
            string bundleH2 = new BundleBuilder(this, "BundleH")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", upgradeVersion }
                }
            }.Build().Output;

            // Install the base bundle.
            BundleInstaller installerH1 = new BundleInstaller(this, bundleH1).Install();

            // Make sure the MSIs are installed.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            Assert.True(MsiVerifier.IsPackageInstalled(packageD1));

            Assert.True(LogVerifier.MessageInLogFileRegex(installerH1.LastLogFile, @"Skipping cross-scope dependency registration on package: PackageA, bundle scope: PerUser, package scope: PerMachine"));

            // Install the upgrade bundle. Verify the base bundle was removed.
            BundleInstaller installerH2 = new BundleInstaller(this, bundleH2).Install();

            // Verify packageD2 was installed and packageD1 was uninstalled.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            Assert.False(MsiVerifier.IsPackageInstalled(packageD1));
            Assert.True(MsiVerifier.IsPackageInstalled(packageD2));

            Assert.True(LogVerifier.MessageInLogFileRegex(installerH2.LastLogFile, @"Skipping cross-scope dependency registration on package: PackageA, bundle scope: PerUser, package scope: PerMachine"));
            Assert.True(LogVerifier.MessageInLogFileRegex(installerH2.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Upgrade, scope: PerUser, version: 1\.0\.0\.0, operation: MajorUpgrade"));

            // Uninstall the upgrade bundle now.
            installerH2.Uninstall();

            // Verify that permanent packageA is still installed and then remove.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            MSIExec.UninstallProduct(packageA, MSIExec.MSIExecReturnCode.SUCCESS);

            // Make sure the MSIs were uninstalled.
            Assert.False(MsiVerifier.IsPackageInstalled(packageA));
            Assert.False(MsiVerifier.IsPackageInstalled(packageD2));

            this.Complete();
        }
コード例 #13
0
        public void Burn_UninstallBundleWithDependent()
        {
            const string expectedVersion = "1.0.0.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the bundles.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();

            // Make sure the MSIs and EXE are installed.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            Assert.True(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.Equal(expectedVersion, actualVersion);
            }

            // Attempt to uninstall bundleA.
            installerA.Uninstall();

            // Verify packageA and ExeA are still installed.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.Equal(expectedVersion, actualVersion);
            }

            // Uninstall bundleB now.
            installerB.Uninstall();

            // Make sure the MSIs are installed.
            Assert.False(MsiVerifier.IsPackageInstalled(packageB));
            Assert.False(MsiVerifier.IsPackageInstalled(packageA));
            Assert.Null(this.GetTestRegistryRoot());

            this.Complete();
        }
コード例 #14
0
        public void Burn_UninstallUpgradedBundle()
        {
            const string expectedVersion1 = "1.0.0.0";
            const string expectedVersion2 = "1.0.1.0";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageA1 = new PackageBuilder(this, "A")
            {
                Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Override the path for A to A1.
            bindPaths["packageA"] = packageA1;
            string bundleA1 = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion2 }
                }
            }.Build().Output;

            // Install the bundles.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();

            // Make sure the MSIs and EXE are installed.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA));
            Assert.True(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.Equal(expectedVersion1, actualVersion);
            }

            // Attempt to upgrade bundleA.
            BundleInstaller installerA1 = new BundleInstaller(this, bundleA1).Install();

            // Verify packageA1 was installed and packageA was uninstalled.
            Assert.True(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.False(MsiVerifier.IsPackageInstalled(packageA));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.Equal(expectedVersion2, actualVersion);
            }

            // Uninstall bundleA1 and verify that packageA1 is still installed.
            installerA1.Uninstall();
            Assert.True(MsiVerifier.IsPackageInstalled(packageA1));

            // Uninstall bundleB now.
            // // SFBUG:3307315, or (new) 2555 - Detect for upgraded package also.
            installerB.Uninstall();

            // Make sure the MSIs are not installed.
            Assert.False(MsiVerifier.IsPackageInstalled(packageB));
            Assert.False(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.False(MsiVerifier.IsPackageInstalled(packageA));
            Assert.Null(this.GetTestRegistryRoot());

            this.Complete();
        }
コード例 #15
0
        public void Burn_InstallPatchBundle()
        {
            const string expectedVersion = "1.0.1.0";

            // Build the packages.
            string packageA1 = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageA2 = new PackageBuilder(this, "A")
            {
                Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion }
                }, NeverGetsInstalled = true
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;
            string patchA = new PatchBuilder(this, "PatchA")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", expectedVersion }
                }, TargetPath = packageA1, UpgradePath = packageA2
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA1);
            bindPaths.Add("packageB", packageB);
            bindPaths.Add("patchA", patchA);

            // Build the bundles.
            string bundleF = new BundleBuilder(this, "BundleF")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleG = new BundleBuilder(this, "BundleG")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the base bundle and make sure all packages are installed.
            BundleInstaller installerF = new BundleInstaller(this, bundleF).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));

            // Install patch bundle and make sure all packages are installed.
            BundleInstaller installerG = new BundleInstaller(this, bundleG).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageB));
            Assert.IsTrue(MsiUtils.IsPatchInstalled(patchA));

            // Uninstall the base bundle and make sure all packages are uninstalled.
            installerF.Uninstall();
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA1));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            Assert.IsFalse(MsiUtils.IsPatchInstalled(patchA));

            this.CleanTestArtifacts = true;
        }
コード例 #16
0
ファイル: Burn.RelatedBundleTests.cs プロジェクト: fyisa/wix3
        public void Burn_InstallUninstallAddonPatchRelatedBundle()
        {
            // Build the packages.
            string packageA  = new PackageBuilder(this, "A").Build().Output;
            string packageC1 = new PackageBuilder(this, "C").Build().Output;
            string packageC2 = new PackageBuilder(this, "C")
            {
                PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", "1.0.1.0" }
                }
            }.Build().Output;
            string packageD = new PackageBuilder(this, "D").Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageC", packageC1);
            bindPaths.Add("packageD", packageD);

            // Build the base and addon bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleC = new BundleBuilder(this, "BundleC")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Update path to C2 and build the addon patch bundle.
            bindPaths["packageC"] = packageC2;
            string bundleE = new BundleBuilder(this, "BundleE")
            {
                BindPaths = bindPaths, Extensions = Extensions, PreprocessorVariables = new Dictionary <string, string>()
                {
                    { "Version", "1.0.1.0" }
                }
            }.Build().Output;

            // Install the base and addon bundles.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
            BundleInstaller installerC = new BundleInstaller(this, bundleC).Install();

            // Test that packages A and C1 but not D are installed.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC1));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC2));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));

            // Install the patch to the addon.
            BundleInstaller installerE = new BundleInstaller(this, bundleE).Install();

            // Test that packages A and C2 but not D are installed, and that C1 was upgraded.
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC1));
            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageC2));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));

            // Attempt to uninstall bundleA.
            installerA.Uninstall();

            // Test that uninstalling bundle A detected and removed bundle C, which removed bundle E (can't easily reference log).
            Assert.IsTrue(LogVerifier.MessageInLogFileRegex(installerA.LastLogFile, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Addon, scope: PerMachine, version: 1\.0\.0\.0, operation: Remove"));

            // Test that all packages are uninstalled.
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC1));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageC2));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageD));

            this.CleanTestArtifacts = true;
        }
コード例 #17
0
        public void Burn_DifferentPackageRequestStates()
        {
            const string expectedVersion = "1.0.0.0";

            // Build the package.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            // Install the base bundle and make sure it's installed.
            BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion, actualVersion);
            }

            // SFBUG:3469206 - install a bundle without installing the shared package, which should not be ref-counted.
            this.SetPackageRequestedState("PackageA", RequestState.None);

            // Also don't install packageB since it has an authored dependency on packageA and would fail this test case.
            this.SetPackageRequestedState("PackageB", RequestState.None);

            BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();

            Assert.IsTrue(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion, actualVersion);
            }

            // Uninstall the first bundle and make sure packageA is uninstalled.
            this.ResetPackageStates("PackageA");
            installerA.Uninstall();
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                string actualVersion = root.GetValue("Version") as string;
                Assert.AreEqual(expectedVersion, actualVersion);
            }

            // Uninstall the second bundle and make sure all packages are uninstalled.
            installerB.Uninstall();
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageA));
            Assert.IsFalse(MsiVerifier.IsPackageInstalled(packageB));
            using (RegistryKey root = this.GetTestRegistryRoot())
            {
                Assert.IsNull(root.GetValue("Version"));
            }

            this.CleanTestArtifacts = true;
        }
コード例 #18
0
        public void Burn_RedirectPackageCache()
        {
            const string PolicyName = "PackageCache";

            // Build the packages.
            string packageA = new PackageBuilder(this, "A")
            {
                Extensions = Extensions
            }.Build().Output;
            string packageB = new PackageBuilder(this, "B")
            {
                Extensions = Extensions
            }.Build().Output;

            // Create the named bind paths to the packages.
            Dictionary <string, string> bindPaths = new Dictionary <string, string>();

            bindPaths.Add("packageA", packageA);
            bindPaths.Add("packageB", packageB);

            // Build the bundles.
            string bundleA = new BundleBuilder(this, "BundleA")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;
            string bundleB = new BundleBuilder(this, "BundleB")
            {
                BindPaths = bindPaths, Extensions = Extensions
            }.Build().Output;

            RegistryKey policy = Registry.LocalMachine.CreateSubKey(@"Software\Policies\WiX\Burn");
            string      currentPackageCache = null;

            try
            {
                currentPackageCache = policy.GetValue(PolicyName) as string;

                // Install the first bundle using the default package cache.
                policy.DeleteValue(PolicyName);

                BundleInstaller installerA = new BundleInstaller(this, bundleA).Install();
                Assert.True(MsiVerifier.IsPackageInstalled(packageA));

                // Install the second bundle which has a shared package using the redirected package cache.
                string path = Path.Combine(Path.GetTempPath(), "Package Cache");
                policy.SetValue(PolicyName, path);

                BundleInstaller installerB = new BundleInstaller(this, bundleB).Install();
                Assert.True(MsiVerifier.IsPackageInstalled(packageA));
                Assert.True(MsiVerifier.IsPackageInstalled(packageB));

                // The first bundle should leave package A behind.
                installerA.Uninstall();

                // Now make sure that the second bundle removes packages from either cache directory.
                installerB.Uninstall();

                this.Complete();
            }
            finally
            {
                if (!string.IsNullOrEmpty(currentPackageCache))
                {
                    policy.SetValue(PolicyName, currentPackageCache);
                }
                else
                {
                    policy.DeleteValue(PolicyName);
                }

                policy.Dispose();
            }
        }