Exemple #1
0
        //specify packagefile to create a new package
        //specify -u oldpackage newpackage to create an update from oldpackage to newpackage
        static int Main(string[] args)
        {
            FileSystem.Current     = new FileSystem();
            TimeService.Current    = new TimeService();
            ArchiveFactory.Current = new ArchiveFactory();

            if (args.Length == 3 && args[1] == "-o")
            {
                try
                {
                    Console.WriteLine("Creating installer package");

                    if (!Directory.Exists(args[0]))
                    {
                        Console.WriteLine("Error: Directory " + args[0] + " not found");
                        return(1);
                    }

                    CreateInstaller(args[0], args[2], file => file.StartsWith(".svn", StringComparison.OrdinalIgnoreCase));

                    PackageMetadata metadata = new PackageMetadata();
                    if (!ValidateInstaller(args[2], metadata))
                    {
                        return(1);
                    }

                    Console.WriteLine("Installer package created");
                    Console.WriteLine("    Version: " + metadata.Version);
                    Console.WriteLine("    MD5: " + metadata.MD5);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex);
                    Console.WriteLine("Installer package creation failed");
                }
            }
            else if (args.Length == 5 && args[0] == "-u" && args[3] == "-o")
            {
                try
                {
                    Console.WriteLine("Creating update installer package");

                    if (!File.Exists(args[1]))
                    {
                        Console.WriteLine("Error: File " + args[1] + " not found");
                        return(1);
                    }

                    GameInstall oldInstall;
                    if (!ValidateNonUpdateInstaller(args[1], out oldInstall))
                    {
                        return(1);
                    }

                    if (!File.Exists(args[2]))
                    {
                        Console.WriteLine("Error: File " + args[2] + " not found");
                        return(1);
                    }

                    GameInstall newInstall;
                    if (!ValidateNonUpdateInstaller(args[2], out newInstall))
                    {
                        return(1);
                    }

                    var details = new UpdateDetails
                    {
                        UpdateVersion = oldInstall.Game.Version
                    };

                    oldInstall.Dispose();
                    newInstall.Dispose();

                    CreateUpdateInstaller(details, args[1], args[2], args[4]);

                    PackageMetadata metadata = new PackageMetadata();
                    if (!ValidateInstaller(args[4], metadata))
                    {
                        return(1);
                    }

                    Console.WriteLine("Installer update package created");
                    Console.WriteLine("    Version: " + metadata.Version);
                    Console.WriteLine("    MD5: " + metadata.MD5);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex);
                    Console.WriteLine("Installer update package creation failed");
                }
            }
            else if (args.Length == 0)
            {
                Console.WriteLine("Usage");
                Console.WriteLine();
                Console.WriteLine("GamesManager.PackageGen <installer package folder> -o <installer package>");
                Console.WriteLine("    Creates a new installer package from a directory.");
                Console.WriteLine("GamesManager.PackageGen -u <old installer package> <new installer package> -o <installer package>");
                Console.WriteLine("    Creates a new installer package that updates the old game to the new one.");
            }
            return(0);
        }
Exemple #2
0
 private static bool ValidateInstaller(string installerFile, PackageMetadata data)
 {
     Console.WriteLine("Validating installer package "+installerFile );
     using (GameInstall install = new GameInstall(installerFile))
     {
         using (Stream stream = new FileStream(installerFile, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             data.MD5 = stream.ComputeMD5();
         }
         return ValidateInstaller(install,data);
     }
 }
Exemple #3
0
 private static bool ValidateInstaller(GameInstall install, PackageMetadata data)
 {
     if (install.ErrorCollection.Count > 0)
     {
         foreach (var error in install.ErrorCollection)
         {
             Console.WriteLine("Error: " + error);
         }
         Console.WriteLine("Error: Installer package creation failed.");
         return false;
     }
     else if ( data !=null )
     {
         data.Version = install.Game.Version;
     }
     return true;
 }
Exemple #4
0
        //specify packagefile to create a new package
        //specify -u oldpackage newpackage to create an update from oldpackage to newpackage
        static int Main(string[] args)
        {
            FileSystem.Current = new FileSystem();
            TimeService.Current = new TimeService();
            ArchiveFactory.Current = new ArchiveFactory();

            if (args.Length==3 && args[1]=="-o")
            {
                try
                {
                    Console.WriteLine("Creating installer package");

                    if (!Directory.Exists(args[0]))
                    {
                        Console.WriteLine("Error: Directory "+args[0]+" not found");
                        return 1;
                    }

                    CreateInstaller(args[0], args[2], file => file.StartsWith(".svn",StringComparison.OrdinalIgnoreCase));

                    PackageMetadata metadata = new PackageMetadata();
                    if (!ValidateInstaller(args[2],metadata)) return 1;

                    Console.WriteLine("Installer package created");
                    Console.WriteLine("    Version: " + metadata.Version);
                    Console.WriteLine("    MD5: " + metadata.MD5);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: "+ex);
                    Console.WriteLine("Installer package creation failed");
                }
            }
            else if (args.Length == 5 && args[0] == "-u" && args[3] == "-o")
            {
                try
                {
                    Console.WriteLine("Creating update installer package");

                    if (!File.Exists(args[1]))
                    {
                        Console.WriteLine("Error: File " + args[1] + " not found");
                        return 1;
                    }

                    GameInstall oldInstall;
                    if (!ValidateNonUpdateInstaller(args[1], out oldInstall)) return 1;

                    if (!File.Exists(args[2]))
                    {
                        Console.WriteLine("Error: File " + args[2] + " not found");
                        return 1;
                    }

                    GameInstall newInstall;
                    if (!ValidateNonUpdateInstaller(args[2],out newInstall)) return 1;

                    var details = new UpdateDetails
                                      {
                                          UpdateVersion = oldInstall.Game.Version
                                      };

                    oldInstall.Dispose();
                    newInstall.Dispose();

                    CreateUpdateInstaller(details, args[1], args[2], args[4]);

                    PackageMetadata metadata = new PackageMetadata();
                    if (!ValidateInstaller(args[4],metadata)) return 1;

                    Console.WriteLine("Installer update package created");
                    Console.WriteLine("    Version: " + metadata.Version);
                    Console.WriteLine("    MD5: " + metadata.MD5);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex);
                    Console.WriteLine("Installer update package creation failed");
                }
            }
            else if (args.Length == 0)
            {
                Console.WriteLine("Usage");
                Console.WriteLine();
                Console.WriteLine("GamesManager.PackageGen <installer package folder> -o <installer package>");
                Console.WriteLine("    Creates a new installer package from a directory.");
                Console.WriteLine("GamesManager.PackageGen -u <old installer package> <new installer package> -o <installer package>");
                Console.WriteLine("    Creates a new installer package that updates the old game to the new one.");
            }
            return 0;
        }