コード例 #1
0
        public void TestSingleFeatureComponents()
        {
            var parameters = new WixBuilderParameters
            {
                Features = new[]
                {
                    new Feature
                    {
                        Id          = "ApplicationFiles",
                        Title       = "Documentation",
                        Description = "all the docs",
                        Content     = new Content
                        {
                            Include = @"Doc\*.*"
                        }
                    }
                }
            };

            WixDocument wix = WixDocumentFor(parameters);

            WixFeature featureElement  = wix.Features.AssertSingle();
            Feature    expectedFeature = parameters.Features[0];

            WixAssert.AssertFeature(expectedFeature, featureElement);

            string       componentRef = featureElement.ComponentReferences.AssertSingle();
            WixComponent docComponent = wix.ResolveComponentReference(componentRef);

            WixAssert.AssertDirectoryComponent(DirectoryFromRoot("Doc"), docComponent);
        }
コード例 #2
0
        public void TestFeaturesReferencesCorrectComponents()
        {
            WixDocument wix = WixDocumentFor(ParametersForMultipleFeaturesTest());

            Assert.AreEqual(2, wix.Features.Count());

            WixFeature   wixFeature   = wix.Features.Where(feature => feature.Id == "Documentation").AssertSingle();
            string       componentRef = wixFeature.ComponentReferences.AssertSingle();
            WixComponent component    = wix.ResolveComponentReference(componentRef);

            WixAssert.AssertDirectoryComponent(DirectoryFromRoot("Doc"), component);
        }
コード例 #3
0
        public void TestCreateFolderIsInjectedInFoldersStoringOnlyShortcuts()
        {
            var parameters = new WixBuilderParameters
            {
                Features = new[]
                {
                    new Feature
                    {
                        Id          = "Documentation",
                        Title       = "Documentation",
                        Description = "all the docs",
                        Content     = new Content
                        {
                            Include = @"Doc\*.*"
                        },

                        Shortcuts = new[]
                        {
                            new Shortcut
                            {
                                Name = "Foo documentation",
                                Path = @"Doc/foo.chm"
                            }
                        }
                    },
                },

                KnownIds = new[]
                {
                    new KnownId
                    {
                        Id   = "foo_help",
                        Path = @"Doc/foo.chm"
                    },
                }
            };

            var wixDocument      = WixDocumentFor(parameters);
            var targetMenuFolder = wixDocument.ResolveDirectoryRef("TargetMenuFolder");

            foreach (var shortcut in targetMenuFolder.Shortcuts)
            {
                WixComponent component = shortcut.ParentElement.ToWix <WixComponent>();
                Assert.AreEqual(0, component.Files.Count());
                Assert.AreEqual(1, component.SelectNodes("wix:CreateFolder").Count);

                AssertPerUserProfileComponentUsesRegistryKeyAsPath(component);
            }
        }
コード例 #4
0
ファイル: WixAssert.cs プロジェクト: superyfwy/db4o
		internal static void AssertDirectoryComponent(IFolder expectedDirectoryLayout, WixComponent actualComponent)
		{
			XmlElement parentDirectory = actualComponent.ParentElement;
			AssertWixDirectory(expectedDirectoryLayout, parentDirectory);

			var actualFiles = actualComponent.Files.GetEnumerator();
			var expectedFiles = expectedDirectoryLayout.Children;
			foreach (var expectedFile in expectedFiles)
			{
				Assert.IsTrue(actualFiles.MoveNext(), "Expecting '" + expectedFile + "'");
				AssertFile(expectedFile, actualFiles.Current);
			}
			if (actualFiles.MoveNext())
				Assert.Fail("Unexpected '" + actualFiles.Current + "'");
		}
コード例 #5
0
        public void TestMultipleEmptyFolders()
        {
            var parameters = new WixBuilderParameters
            {
                Features = new[]
                {
                    new Feature
                    {
                        Id          = "ApplicationFiles",
                        Title       = "Documentation",
                        Description = "all the docs",
                        Content     = new Content
                        {
                            Include = @"native\**\*.*"
                        }
                    }
                }
            };

            WixDocument wix = WixDocumentFor(parameters);

            WixFeature featureElement  = wix.Features.AssertSingle();
            Feature    expectedFeature = parameters.Features[0];

            WixAssert.AssertFeature(expectedFeature, featureElement);

            string       componentRef    = featureElement.ComponentReferences.AssertSingle();
            WixComponent configComponent = wix.ResolveComponentReference(componentRef);

            WixAssert.AssertDirectoryComponent(DirectoryFromRoot("native/Db4objects.Db4o/Config"), configComponent);

            WixDirectory configDirectory = configComponent.ParentElement.ToWix <WixDirectory>();

            Assert.AreEqual(DirectoryFromRoot("native/Db4objects.Db4o/Config").Name, configDirectory.Name);
            Assert.AreEqual(DirectoryFromRoot("native/Db4objects.Db4o").Name, configDirectory.ParentElement.ToWix <WixDirectory>().Name);
            Assert.AreEqual(DirectoryFromRoot("native").Name, configDirectory.ParentElement.ToWix <WixDirectory>().ParentElement.ToWix <WixDirectory>().Name);
        }
コード例 #6
0
ファイル: WixComponentGroup.cs プロジェクト: jtefd/WixCSBuild
 public void AddComponent(WixComponent component)
 {
     AddTag(component);
 }
コード例 #7
0
ファイル: WixAssert.cs プロジェクト: azureskydiver/db4objects
        internal static void AssertDirectoryComponent(IFolder expectedDirectoryLayout, WixComponent actualComponent)
        {
            XmlElement parentDirectory = actualComponent.ParentElement;

            AssertWixDirectory(expectedDirectoryLayout, parentDirectory);

            var actualFiles   = actualComponent.Files.GetEnumerator();
            var expectedFiles = expectedDirectoryLayout.Children;

            foreach (var expectedFile in expectedFiles)
            {
                Assert.IsTrue(actualFiles.MoveNext(), "Expecting '" + expectedFile + "'");
                AssertFile(expectedFile, actualFiles.Current);
            }
            if (actualFiles.MoveNext())
            {
                Assert.Fail("Unexpected '" + actualFiles.Current + "'");
            }
        }
コード例 #8
0
 private static void AssertPerUserProfileComponentUsesRegistryKeyAsPath(WixComponent component)
 {
     Assert.GreaterOrEqual(component.SelectNodes("wix:RegistryValue").Count, 1);
 }
コード例 #9
0
		private static void AssertPerUserProfileComponentUsesRegistryKeyAsPath(WixComponent component)
		{
			Assert.GreaterOrEqual(component.SelectNodes("wix:RegistryValue").Count, 1);
		}
コード例 #10
0
ファイル: BuildManager.cs プロジェクト: jtefd/WixCSBuild
        public void build()
        {
            wix = new Wix();

            DirectoryInfo dirinfo = new DirectoryInfo(buildConfig.Directory);

            name = dirinfo.Name;

            buildDir = new DirectoryInfo(Environment.GetEnvironmentVariable("TMP")).CreateSubdirectory(WixUtil.MD5Sum(dirinfo.FullName));

            if (buildDir.Exists)
            {
                buildDir.Delete(true);
            }

            buildDir.Create();

            Console.WriteLine("Using temporary directory: {0}", buildDir.FullName);

            WixProduct product = new WixProduct(
                buildConfig.PackageFullTitle,
                buildConfig.Manufacturer,
                WixUtil.ConvertVersion(buildConfig.Version),
                WixUtil.GenUpgradeGuid(buildConfig.PackageName)
            );

            product.AddPackage(new WixPackage(true));
            product.AddMedia(new WixMedia(1, "product.cab", true));

            WixDirectory app_root = WixDirectory.CreateApplicationRoot(buildConfig.PackageName);
            WixDirectory pfiles = WixDirectory.ProgramFiles;
            WixDirectory smenu = WixDirectory.StartMenu;
            WixDirectory target = WixDirectory.Target;

            pfiles.AddDirectory(app_root);
            target.AddDirectory(pfiles);
            target.AddDirectory(smenu);

            WixDirectory start_menu_dir = new WixDirectory(buildConfig.PackageFullTitle);

            smenu.AddDirectory(start_menu_dir);

            product.AddDirectory(target);

            FileHarvest harvest = new FileHarvest(dirinfo.FullName);

            WixDirectoryRef app_root_ref = app_root.DirectoryRef;

            WixComponentGroup comp_group = harvest.ProcessDirectory(app_root_ref);

            if (buildConfig.Path)
            {
                WixComponent env_comp = new WixComponent("env_path");
                env_comp.AddGuid("Guid");
                env_comp.AddEnvironment(new WixEnvironment("path", "set", false, false, "last", "[APPLICATIONROOTDIRECTORY]"));
                env_comp.KeyPath = true;

                comp_group.AddComponentRef(env_comp.ComponentRef);
                app_root_ref.AddComponent(env_comp);
            }

            if (buildConfig.Shortcut != null)
            {
                FileInfo shortcut_file = new FileInfo(buildConfig.Shortcut);

                if (shortcut_file.Exists)
                {
                    //string id = "";

                    foreach (XmlElement element in (app_root_ref.GetTag().SelectNodes("//File")))
                    {
                        if (element.GetAttribute("Source").ToUpper().Equals(shortcut_file.FullName.ToUpper()))
                        {
                            //id = element.GetAttribute("Id");

                            WixShortcut shortcut = new WixShortcut(new FileInfo(buildConfig.Shortcut).Name, new FileInfo(buildConfig.Shortcut).Name, start_menu_dir.Id, "INSTALLDIR", false);

                            element.AppendChild(shortcut.GetTag());
                        }
                    }
                }
            }

            product.AddDirectoryRef(app_root_ref);
            product.AddComponentGroup(comp_group);

            WixFeature feature = new WixFeature("Main", 1);
            feature.AddComponentGroupRef(comp_group.ComponentGroupRef);

            product.AddFeature(feature);

            product.AddUIRef(WixUIRef.Custom);
            product.AddProperty(new WixProperty("wixui_installdir", app_root.Id));

            WixUpgrade upgrade = new WixUpgrade(product.GetTag().GetAttribute("UpgradeCode"));
            upgrade.AddUpgradeVersion(new WixUpgradeVersion("0.0.0.1", true, buildConfig.Version, false));

            product.AddUpgrade(upgrade);

            WixInstallExecuteSequence i_exec_seq = new WixInstallExecuteSequence();
            i_exec_seq.AddRemoveExistingProducts();

            product.AddTag(i_exec_seq);

            wix.addProduct(product);

            Candle();
            Light();
        }