//This will set the current launcher version within the installer manifest of the passed in installerDirectory
        public static void SetLauncherVersion(int newLauncherVersion, string installerDirectory)
        {
            var doc = XDocument.Load(installerDirectory + "InstallerManifest.xml");

            doc.Descendants().Single(p => p.Name == "LauncherVersion").Value = newLauncherVersion.ToString();
            SaveXmlDoc.saveManifestDoc(installerDirectory, doc);
        }
示例#2
0
        //This creates a manifest file whenever the back end installs. This manifest file is used by the
        //Front end installer to know what files to copy.
        public static void CreateManifestXMLFile(string locationToPlaceManifest, List <DTO.InstallerItem> installerManifest)
        {
            var            doc            = new XmlDocument();
            XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            XmlElement root = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);

            XmlElement topElement = doc.CreateElement("Base");

            doc.AppendChild(topElement);


            XmlElement launcherVersion = doc.CreateElement("LauncherVersion");

            launcherVersion.InnerText = "1";
            topElement.AppendChild(launcherVersion);

            XmlElement baseDoc = doc.CreateElement("InstallerManifest");

            topElement.AppendChild(baseDoc);

            //Add each item in the manifest to the XML document, stripping out the full path
            foreach (var item in installerManifest)
            {
                FileInfo   file        = new FileInfo(item.DestinationFilePath);
                XmlElement fileElement = doc.CreateElement("File");
                string     fileName    = item.DestinationFilePath.Replace(locationToPlaceManifest, "");
                fileElement.SetAttribute("RelativePath", file.Name);
                fileElement.SetAttribute("FullPath", file.FullName);
                baseDoc.AppendChild(fileElement);
            }
            SaveXmlDoc.saveManifestDoc(locationToPlaceManifest, doc);
        }
        //This will add the passed in file to the installer manifest within the passed in installerDirectory
        public static void AddFileToManifest(string installerDirectory, FileInfo file)
        {
            var doc       = XDocument.Load(installerDirectory + "InstallerManifest.xml");
            var sameFiles = doc.Descendants("File").Select(p => new FileInfo(p.Attribute("FullPath").Value)).Where(p => p.Name == file.Name);

            if (sameFiles.Count() == 0)
            {
                doc.Descendants().Single(p => p.Name == "InstallerManifest").Add(
                    new XElement("File",
                                 new XAttribute("RelativePath", file.FullName.Replace(installerDirectory, "")),
                                 new XAttribute("FullPath", file.FullName)));
                SaveXmlDoc.saveManifestDoc(installerDirectory, doc);
            }
        }