예제 #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 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);
        }
예제 #4
0
 internal static void AssertFeature(Feature expectedFeature, WixFeature featureElement)
 {
     Assert.AreEqual(expectedFeature.Id, featureElement.Id);
     Assert.AreEqual(expectedFeature.Title, featureElement.Title);
     Assert.AreEqual(expectedFeature.Description, featureElement.Description);
 }
예제 #5
0
파일: WixAssert.cs 프로젝트: superyfwy/db4o
		internal static void AssertFeature(Feature expectedFeature, WixFeature featureElement)
		{
			Assert.AreEqual(expectedFeature.Id, featureElement.Id);
			Assert.AreEqual(expectedFeature.Title, featureElement.Title);
			Assert.AreEqual(expectedFeature.Description, featureElement.Description);
		}
예제 #6
0
        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();
        }