/// <summary>
        /// Emits the XML.
        /// </summary>
        public XContainer ToXml()
        {
            var element = new XElement("Environment",
                                       new XAttribute("Id", Id),
                                       new XAttribute("Name", Name),
                                       new XAttribute("Action", Action));

            if (Part.HasValue)
            {
                element.Add(new XAttribute("Part", Part.Value));
            }

            if (Value != null)
            {
                element.Add(new XAttribute("Value", Value));
            }

            if (System.HasValue)
            {
                element.Add(new XAttribute("System", System.Value.ToYesNo()));
            }

            if (Permanent.HasValue)
            {
                element.Add(new XAttribute("Permanent", Permanent.Value.ToYesNo()));
            }

            element.AddAttributes(Attributes);

            return(element);
        }
Exemple #2
0
        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public override XContainer[] ToXml()
        {
            var root = new XElement("MsiPackage");

            root.SetAttribute("Name", Name); //will respect null

            if (this.IsIdSet())
            {
                root.SetAttribute("Id", Id);
            }

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

            if (Payloads.Any())
            {
                Payloads.ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p))));
            }

            string props = MsiProperties + ";" + DefaultMsiProperties;

            props.ToDictionary().ForEach(p =>
            {
                root.Add(new XElement("MsiProperty").AddAttributes("Name={0};Value={1}".FormatWith(p.Key, p.Value)));
            });

            return(new[] { root });
        }
Exemple #3
0
        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public override XContainer[] ToXml()
        {
            var root = new XElement("ExePackage");

            root.SetAttribute("Name", Name); //will respect null

            if (this.IsIdSet())
            {
                root.SetAttribute("Id", Id);
            }

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

            if (Payloads.Any())
            {
                Payloads.ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p))));
            }

            foreach (var exitCode in ExitCodes)
            {
                root.Add(exitCode.ToXElement());
            }
            return(new[] { root });
        }
Exemple #4
0
        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public override XContainer[] ToXml()
        {
            var root = new XElement("MsuPackage");

            root.SetAttribute("Name", Name); //will respect null

            if (this.IsIdSet())
            {
                root.SetAttribute("Id", Id);
            }

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

            if (Payloads.Any())
            {
                Payloads.ForEach(p => root.Add(p.ToXElement("Payload")));
            }

            if (RemotePayloads.Any())
            {
                RemotePayloads.ForEach(p => root.Add(p.ToXElement("RemotePayload")));
            }

            return(new[] { root });
        }
Exemple #5
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());
        }
Exemple #6
0
        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public override XContainer[] ToXml()
        {
            var root = new XElement("PackageGroupRef");

            if (this.IsIdSet())
            {
                root.SetAttribute("Id", Id);
            }

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

            return(new[] { root });
        }
Exemple #7
0
        static public void EmitAttributes(this Shortcut shortcut, XElement shortcutElement)
        {
            shortcutElement.AddAttributes(shortcut.Attributes);

            if (shortcut.Arguments == "" && shortcutElement.Attribute("Arguments") != null)
            {
                shortcutElement.Attribute("Arguments").Remove();
            }

            if (shortcut.Advertise)
            {
                shortcutElement.Add(new XAttribute("Advertise", "yes"));
            }

            if (!shortcut.IconFile.IsEmpty())
            {
                shortcutElement.Add(new XAttribute("Icon", shortcut.IconFile)); //note the IconFile will be converted into Icon (ID) in the AutoElements.InjectAutoElementsHandler(...)
                shortcutElement.Add(new XAttribute("IconIndex", shortcut.IconIndex));
            }
        }
Exemple #8
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());
        }