Пример #1
0
        static void Main(string[] args)
        {
            // Get our .exe folder path:
            var exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            if (exePath == null)
                throw new Exception("So sorry, don't know where we are!");
            ExeFolder = Path.GetDirectoryName(exePath);

            // Test that installer given on command line exists:
            if (args.Count() < 1)
                throw new Exception("Must specify installer file in command line.");

            var installerFilePath = args[0];

            if (!File.Exists(installerFilePath))
                throw new Exception("Installer file '" + installerFilePath + "' does not exist.");

            var libExtractor = new LibraryExtractor(installerFilePath);
            libExtractor.ExtractFileLibrary();

            /*
            // Test against existing Library (for use in testing this program):
            string errors = "";
            var xmlLib = new XmlDocument();
            xmlLib.Load("FileLibrary.xml");
            var xmlNewAddenda = new XmlDocument();
            xmlNewAddenda.Load("__FileLibraryAddenda.xml");

            var libNodes = xmlLib.SelectNodes("//File");

            foreach (XmlElement libNode in libNodes)
            {
                var path = libNode.GetAttribute("Path");
                var componentGuid = libNode.GetAttribute("ComponentGuid");
                var longName = libNode.GetAttribute("LongName");
                var directoryId = libNode.GetAttribute("DirectoryId");
                var featureList = libNode.GetAttribute("FeatureList");

                var newNode = xmlNewAddenda.SelectSingleNode("//File[@ComponentGuid=\"" + componentGuid + "\"]") as XmlElement;
                if (newNode == null)
                {
                    errors += "File with Guid " + componentGuid + " exists in Library but not in new Addenda." + Environment.NewLine;
                    continue;
                }
                var newPath = newNode.GetAttribute("Path");
                var newLongName = newNode.GetAttribute("LongName");
                var newDirectoryId = newNode.GetAttribute("DirectoryId");
                var newFeatureList = newNode.GetAttribute("FeatureList");

                if (path != newPath)
                {
                    errors += "File with Guid " + componentGuid + " has path '" + path + "' in Library but in new Addenda it is '" +
                              newPath + "'." + Environment.NewLine;
                    continue;
                }
                if (newLongName != longName)
                    errors += "File with path " + path + " has LongName '" + longName + "' in Library but in new Addenda it is '" + newLongName + "'." + Environment.NewLine;
                if (newDirectoryId != directoryId)
                    errors += "File with path " + path + " has DirectoryId '" + directoryId + "' in Library but in new Addenda it is '" + newDirectoryId + "'." + Environment.NewLine;
                if (newFeatureList != featureList)
                    errors += "File with path " + path + " has FeatureList '" + featureList + "' in Library but in new Addenda it is '" + newFeatureList + "'." + Environment.NewLine;
            }

            libNodes = xmlNewAddenda.SelectNodes("//File");

            foreach (XmlElement libNode in libNodes)
            {
                var componentGuid = libNode.GetAttribute("ComponentGuid");

                var oldNode = xmlLib.SelectSingleNode("//File[@ComponentGuid=\"" + componentGuid + "\"]") as XmlElement;
                if (oldNode == null)
                {
                    errors += "File with Guid " + componentGuid + " exists in new Addenda but not in Library." + Environment.NewLine;
                    continue;
                }
            }
            var output = new StreamWriter("__Errors.txt");
            output.WriteLine(errors);
            output.Close();
             */
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Get our .exe folder path:
            var exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            if (exePath == null)
            {
                throw new Exception("So sorry, don't know where we are!");
            }
            ExeFolder = Path.GetDirectoryName(exePath);

            // Test that installer given on command line exists:
            if (args.Count() < 1)
            {
                throw new Exception("Must specify installer file in command line.");
            }

            var installerFilePath = args[0];

            if (!File.Exists(installerFilePath))
            {
                throw new Exception("Installer file '" + installerFilePath + "' does not exist.");
            }

            var libExtractor = new LibraryExtractor(installerFilePath);

            libExtractor.ExtractFileLibrary();



/*
 *                      // Test against existing Library (for use in testing this program):
 *                      string errors = "";
 *                      var xmlLib = new XmlDocument();
 *                      xmlLib.Load("FileLibrary.xml");
 *                      var xmlNewAddenda = new XmlDocument();
 *                      xmlNewAddenda.Load("__FileLibraryAddenda.xml");
 *
 *                      var libNodes = xmlLib.SelectNodes("//File");
 *
 *                      foreach (XmlElement libNode in libNodes)
 *                      {
 *                              var path = libNode.GetAttribute("Path");
 *                              var componentGuid = libNode.GetAttribute("ComponentGuid");
 *                              var longName = libNode.GetAttribute("LongName");
 *                              var directoryId = libNode.GetAttribute("DirectoryId");
 *                              var featureList = libNode.GetAttribute("FeatureList");
 *
 *                              var newNode = xmlNewAddenda.SelectSingleNode("//File[@ComponentGuid=\"" + componentGuid + "\"]") as XmlElement;
 *                              if (newNode == null)
 *                              {
 *                                      errors += "File with Guid " + componentGuid + " exists in Library but not in new Addenda." + Environment.NewLine;
 *                                      continue;
 *                              }
 *                              var newPath = newNode.GetAttribute("Path");
 *                              var newLongName = newNode.GetAttribute("LongName");
 *                              var newDirectoryId = newNode.GetAttribute("DirectoryId");
 *                              var newFeatureList = newNode.GetAttribute("FeatureList");
 *
 *                              if (path != newPath)
 *                              {
 *                                      errors += "File with Guid " + componentGuid + " has path '" + path + "' in Library but in new Addenda it is '" +
 *                                                        newPath + "'." + Environment.NewLine;
 *                                      continue;
 *                              }
 *                              if (newLongName != longName)
 *                                      errors += "File with path " + path + " has LongName '" + longName + "' in Library but in new Addenda it is '" + newLongName + "'." + Environment.NewLine;
 *                              if (newDirectoryId != directoryId)
 *                                      errors += "File with path " + path + " has DirectoryId '" + directoryId + "' in Library but in new Addenda it is '" + newDirectoryId + "'." + Environment.NewLine;
 *                              if (newFeatureList != featureList)
 *                                      errors += "File with path " + path + " has FeatureList '" + featureList + "' in Library but in new Addenda it is '" + newFeatureList + "'." + Environment.NewLine;
 *                      }
 *
 *                      libNodes = xmlNewAddenda.SelectNodes("//File");
 *
 *                      foreach (XmlElement libNode in libNodes)
 *                      {
 *                              var componentGuid = libNode.GetAttribute("ComponentGuid");
 *
 *                              var oldNode = xmlLib.SelectSingleNode("//File[@ComponentGuid=\"" + componentGuid + "\"]") as XmlElement;
 *                              if (oldNode == null)
 *                              {
 *                                      errors += "File with Guid " + componentGuid + " exists in new Addenda but not in Library." + Environment.NewLine;
 *                                      continue;
 *                              }
 *                      }
 *                      var output = new StreamWriter("__Errors.txt");
 *                      output.WriteLine(errors);
 *                      output.Close();
 */
        }