ToXml() public abstract method

Emits WiX XML.
public abstract ToXml ( ) : System.Xml.Linq.XContainer[]
return System.Xml.Linq.XContainer[]
Esempio n. 1
0
        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public XContainer[] ToXml()
        {
            var result = new List <XContainer>();

            var root = new XElement("Bundle",
                                    new XAttribute("Name", Name));

            root.AddAttributes(this.Attributes);
            root.Add(this.MapToXmlAttributes());

            if (Application is ManagedBootstrapperApplication)
            {
                var app = Application as ManagedBootstrapperApplication;
                if (app.PrimaryPackageId == null)
                {
                    var lastPackage = Chain.OfType <WixSharp.Bootstrapper.Package>().LastOrDefault();
                    if (lastPackage != null)
                    {
                        lastPackage.EnsureId();
                        app.PrimaryPackageId = lastPackage.Id;
                    }
                }

                //addresses https://wixsharp.codeplex.com/workitem/149
                if (!SuppressWixMbaPrereqVars)
                {
                    WixVariables["WixMbaPrereqPackageId"] = "Netfx4Full";
                    WixVariables.Add("WixMbaPrereqLicenseUrl", "NetfxLicense.rtf");
                }
            }

            //important to call AutoGenerateSources after PrimaryPackageId is set
            Application.AutoGenerateSources(this.OutDir);

            root.Add(Application.ToXml());

            string variabes = this.StringVariablesDefinition + ";" + Application.StringVariablesDefinition;

            Compiler.ProcessWixVariables(this, root);

            foreach (var entry in variabes.ToDictionary())
            {
                root.AddElement("Variable", "Name=" + entry.Key + ";Value=" + entry.Value + ";Persisted=yes;Type=string");
            }

            var xChain = root.AddElement("Chain");

            foreach (var item in this.Chain)
            {
                xChain.Add(item.ToXml());
            }

            xChain.SetAttribute("DisableRollback", DisableRollback);
            xChain.SetAttribute("DisableSystemRestore", DisableSystemRestore);
            xChain.SetAttribute("ParallelCache", ParallelCache);

            result.Add(root);
            return(result.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public XContainer[] ToXml()
        {
            var result = new List <XContainer>();

            var root = new XElement("Bundle",
                                    new XAttribute("Name", Name));

            root.AddAttributes(this.Attributes);
            root.Add(this.MapToXmlAttributes());

            if (Application is ManagedBootstrapperApplication app)
            {
                if (app.PrimaryPackageId == null)
                {
                    var lastPackage = Chain.OfType <WixSharp.Bootstrapper.Package>().LastOrDefault();
                    if (lastPackage != null)
                    {
                        lastPackage.EnsureId();
                        app.PrimaryPackageId = lastPackage.Id;
                    }
                }

                //addresses https://wixsharp.codeplex.com/workitem/149
                if (!SuppressWixMbaPrereqVars)
                {
                    WixVariables["WixMbaPrereqPackageId"] = "Netfx4Full";
                    WixVariables.Add("WixMbaPrereqLicenseUrl", "NetfxLicense.rtf");
                }
            }

            //important to call AutoGenerateSources after PrimaryPackageId is set
            Application.AutoGenerateSources(this.OutDir);

            root.Add(Application.ToXml());

            var all_variabes = new List <Variable>();

            all_variabes.AddRange(this.Variables);
            all_variabes.AddRange(Application.Variables);

            if (Application is IWixSharpManagedBootstrapperApplication wsApp)
            {
                if (wsApp.DowngradeWarningMessage.IsNotEmpty())
                {
                    all_variabes.Add(new Variable("DowngradeWarningMessage", wsApp.DowngradeWarningMessage));
                }
            }

            Compiler.ProcessWixVariables(this, root);

            var context = new ProcessingContext
            {
                Project = this,
                Parent  = this,
                XParent = root,
            };

            foreach (IGenericEntity item in all_variabes)
            {
                item.Process(context);
            }

            foreach (IGenericEntity item in GenericItems)
            {
                item.Process(context);
            }

            var xChain = root.AddElement("Chain");

            foreach (var item in this.Chain)
            {
                xChain.Add(item.ToXml());
            }

            xChain.SetAttribute("DisableRollback", DisableRollback);
            xChain.SetAttribute("DisableSystemRestore", DisableSystemRestore);
            xChain.SetAttribute("ParallelCache", ParallelCache);

            result.Add(root);
            return(result.ToArray());
        }