Пример #1
0
        /// <summary>
        /// Replaces text in a file.
        /// </summary>
        /// <param name="filePath">The path to the file to replace the text in.</param>
        /// <param name="regexes">The regexes to use to replace the contents.</param>
        static void DoReplace(string filePath, RegexCollection regexes)
        {
            var txt = File.ReadAllText(filePath, Encoding.UTF8);

            txt = regexes.ReplaceMatches(txt, string.Empty);
            File.WriteAllText(filePath, txt, Encoding.UTF8);
        }
Пример #2
0
 /// <summary>
 /// Replaces text in a file.
 /// </summary>
 /// <param name="filePath">The path to the file to replace the text in.</param>
 /// <param name="regexes">The regexes to use to replace the contents.</param>
 static void DoReplace(string filePath, RegexCollection regexes)
 {
     var txt = File.ReadAllText(filePath, Encoding.UTF8);
     txt = regexes.ReplaceMatches(txt, string.Empty);
     File.WriteAllText(filePath, txt, Encoding.UTF8);
 }
Пример #3
0
        static void Main()
        {
            string netgoreRootRegexed = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "../../../../").Replace("\\", "\\\\");

            _delFileRegexes = new RegexCollection(_deleteFilePatterns.Select(x => x.Replace("/ROOT/", netgoreRootRegexed)));
            _preFileRegexes = new RegexCollection(_preserveFilePatterns.Select(x => x.Replace("/ROOT/", netgoreRootRegexed)));

            // Hmm, spend my time programming, or making ASCII art...
            Console.WriteLine(@"             __          __     _____  _   _ _____ _   _  _____");
            Console.WriteLine(@"             \ \        / /\   |  __ \| \ | |_   _| \ | |/ ____|");
            Console.WriteLine(@"              \ \  /\  / /  \  | |__) |  \| | | | |  \| | |  __ ");
            Console.WriteLine(@"               \ \/  \/ / /\ \ |  _  /| . ` | | | | . ` | | |_ |");
            Console.WriteLine(@"                \  /\  / ____ \| | \ \| |\  |_| |_| |\  | |__| |");
            Console.WriteLine(@"                 \/  \/_/    \_\_|  \_\_| \_|_____|_| \_|\_____|");
            Console.WriteLine();
            Console.WriteLine("                          DO NOT RUN THIS PROGRAM!");
            Console.WriteLine();
            Console.WriteLine(
                "This program is intended to be run ONLY by Spodi for setting up official releases. Running this program WILL alter your database contents and DELETE many files!");
            Console.WriteLine();

            if (!IsSpodi())
            {
                // Screen of doom!
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine(@"______________________");
                Console.WriteLine(@"|\/        |         /          _.--""""""""""--._          (,_    ,_,    _,)");
                Console.WriteLine(@"|/\________|_______ /         .'             '.        /|\`-._( )_.-'/|\");
                Console.WriteLine(@"| /\       |       /         /                 \      / | \`-'/ \'-`/ | \");
                Console.WriteLine(@"|/  \______|_____ /         ;                   ;    /__|.-'`-\_/-`'-.|__\");
                Console.WriteLine(@"|  / \     |     /          |                   |   `          ""          `");
                Console.WriteLine(@"| /   \____|____/           |                   |");
                Console.WriteLine(@"|/    /\   |   /            ;                   ;");
                Console.WriteLine(@"|    /  \__|__/|             \ (`'--,   ,--'`) /");
                Console.WriteLine(@"|   /   /\ | / |              ) )(')/ _ \(')( (");
                Console.WriteLine(@"|   |  /  \|/  |             (_ `""""` / \ `""""` _)");
                Console.WriteLine(@"|----------/   |              \`'-, /   \ ,-'`/");
                Console.WriteLine(@"|   |  |  /    |               `\ / `'`'` \ /`");
                Console.WriteLine(@"|   |  | / / / | \ \            | _. ; ; ._ |");
                Console.WriteLine(@"|   |  \/ / /  |  \ \           |\ '-'-'-' /|");
                Console.WriteLine(@"|\   \ /  \ \_(*)_/ /           | | _ _ _ | |    _..__.          .__.._");
                Console.WriteLine(@"| \   /    \_(~:~)_/             \ '.;_;.' /.   ^""-.._ '-(\__/)-' _..-""^");
                Console.WriteLine(@"|  \ /      /-(:)-\               \       /           '-.' oo '.-'");
                Console.WriteLine(@"|   /      / / * \ \               ',___,'               `-..-'");
                Console.WriteLine(@"|  /       \ \   / /                q___p");
                Console.WriteLine(@"| /         \     /                 q___p");
                Console.WriteLine(@"|/                                  q___p");
                Console.WriteLine(@"");
                Console.WriteLine("     IMPOSTER! You are not Spodi! Press any key to terminate program...");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("Root clean directory: " + Paths.Root);

            // Validate run dir
            if (!IsValidRootDir())
            {
                Console.WriteLine("This program may only be run from the project's default build path!");
                Console.WriteLine("Press any key to exit...");
                Console.ReadLine();
                return;
            }

            // Save the schema file
            Console.WriteLine("Updating the database schema file...");
            var schemaFile = Paths.Root + MySqlHelper.DbSchemaFile;
            if (File.Exists(schemaFile))
                File.Delete(schemaFile);

            SchemaSaver.Save();

            if (!File.Exists(schemaFile))
            {
                Console.WriteLine("Failed to create database schema file! Path: {0}", schemaFile);
                Console.WriteLine("Press any key to exit...");
                Console.ReadLine();
                return;
            }

#pragma warning disable 162
            if (_buildSchemaOnly)
            {
                Console.WriteLine("_buildSchemaOnly is set - will not progress any farther.");
                Console.WriteLine("Done!");
                return;
            }
#pragma warning restore 162

            // Remove version control references
            Console.WriteLine("Deleting version control references...");
            VersionControlCleaner.Run(Paths.Root);

            // Delete crap
            Console.WriteLine("Deleting unneeded files/folders...");
            Deleter.RecursiveDelete(Paths.Root, WillDeleteFile);

            var p = Path.Combine(Paths.Root, "Tools", "PngOptimizer");
            Directory.Delete(p, true);

            p = Path.Combine(Paths.Root, "Tools", "IllegalEventCallFinder");
            Directory.Delete(p, true);

            // Create self-destroying batch file that will delete this program's binaries
            Console.WriteLine("Creating self-destruct batch file...");
            var programPath = string.Format("{0}CodeReleasePreparer{1}", Paths.Root, Path.DirectorySeparatorChar);
            RunBatchFile(true, "CHOICE /c 1 /d 1 /t 2 > nul", "RMDIR /S /Q \"" + programPath + "bin\"",
                "RMDIR /S /Q \"" + programPath + "obj\"", "DEL %0");

            Console.WriteLine("Done");
        }
Пример #4
0
        static void Main()
        {
            _delFileRegexes = new RegexCollection(_deleteFilePatterns);
            _preFileRegexes = new RegexCollection(_preserveFilePatterns);

            // Hmm, spend my time programming, or making ASCII art...
            Console.WriteLine(@"             __          __     _____  _   _ _____ _   _  _____");
            Console.WriteLine(@"             \ \        / /\   |  __ \| \ | |_   _| \ | |/ ____|");
            Console.WriteLine(@"              \ \  /\  / /  \  | |__) |  \| | | | |  \| | |  __ ");
            Console.WriteLine(@"               \ \/  \/ / /\ \ |  _  /| . ` | | | | . ` | | |_ |");
            Console.WriteLine(@"                \  /\  / ____ \| | \ \| |\  |_| |_| |\  | |__| |");
            Console.WriteLine(@"                 \/  \/_/    \_\_|  \_\_| \_|_____|_| \_|\_____|");
            Console.WriteLine();
            Console.WriteLine("                          DO NOT RUN THIS PROGRAM!");
            Console.WriteLine();
            Console.WriteLine(
                "This program is intended to be run ONLY by Spodi for setting up official releases. Running this program WILL alter your database contents and DELETE many files!");
            Console.WriteLine();

            if (!IsSpodi())
            {
                // Screen of doom!
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine(@"______________________");
                Console.WriteLine(@"|\/        |         /          _.--""""""""""--._          (,_    ,_,    _,)");
                Console.WriteLine(@"|/\________|_______ /         .'             '.        /|\`-._( )_.-'/|\");
                Console.WriteLine(@"| /\       |       /         /                 \      / | \`-'/ \'-`/ | \");
                Console.WriteLine(@"|/  \______|_____ /         ;                   ;    /__|.-'`-\_/-`'-.|__\");
                Console.WriteLine(@"|  / \     |     /          |                   |   `          ""          `");
                Console.WriteLine(@"| /   \____|____/           |                   |");
                Console.WriteLine(@"|/    /\   |   /            ;                   ;");
                Console.WriteLine(@"|    /  \__|__/|             \ (`'--,   ,--'`) /");
                Console.WriteLine(@"|   /   /\ | / |              ) )(')/ _ \(')( (");
                Console.WriteLine(@"|   |  /  \|/  |             (_ `""""` / \ `""""` _)");
                Console.WriteLine(@"|----------/   |              \`'-, /   \ ,-'`/");
                Console.WriteLine(@"|   |  |  /    |               `\ / `'`'` \ /`");
                Console.WriteLine(@"|   |  | / / / | \ \            | _. ; ; ._ |");
                Console.WriteLine(@"|   |  \/ / /  |  \ \           |\ '-'-'-' /|");
                Console.WriteLine(@"|\   \ /  \ \_(*)_/ /           | | _ _ _ | |    _..__.          .__.._");
                Console.WriteLine(@"| \   /    \_(~:~)_/             \ '.;_;.' /.   ^""-.._ '-(\__/)-' _..-""^");
                Console.WriteLine(@"|  \ /      /-(:)-\               \       /           '-.' oo '.-'");
                Console.WriteLine(@"|   /      / / * \ \               ',___,'               `-..-'");
                Console.WriteLine(@"|  /       \ \   / /                q___p");
                Console.WriteLine(@"| /         \     /                 q___p");
                Console.WriteLine(@"|/                                  q___p");
                Console.WriteLine(@"");
                Console.WriteLine("     IMPOSTER! You are not Spodi! Press any key to terminate program...");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("Root clean directory: " + Paths.Root);

            // Validate run dir
            if (!IsValidRootDir())
            {
                Console.WriteLine("This program may only be run from the project's default build path!");
                Console.WriteLine("Press any key to exit...");
                Console.ReadLine();
                return;
            }

            // Save the schema file
            Console.WriteLine("Updating the database schema file...");
            var schemaFile = Paths.Root + MySqlHelper.DbSchemaFile;

            if (File.Exists(schemaFile))
            {
                File.Delete(schemaFile);
            }

            SchemaSaver.Save();

            if (!File.Exists(schemaFile))
            {
                Console.WriteLine("Failed to create database schema file! Path: {0}", schemaFile);
                Console.WriteLine("Press any key to exit...");
                Console.ReadLine();
                return;
            }

#pragma warning disable 162
            if (_buildSchemaOnly)
            {
                Console.WriteLine("_buildSchemaOnly is set - will not progress any farther.");
                Console.WriteLine("Done!");
                return;
            }
#pragma warning restore 162

            // Remove version control references
            Console.WriteLine("Deleting version control references...");
            VersionControlCleaner.Run(Paths.Root);

            // Delete crap
            Console.WriteLine("Deleting unneeded files/folders...");
            Deleter.RecursiveDelete(Paths.Root, WillDeleteFile);

            var p = Path.Combine(Paths.Root, "Tools", "PngOptimizer");
            Directory.Delete(p, true);

            p = Path.Combine(Paths.Root, "Tools", "IllegalEventCallFinder");
            Directory.Delete(p, true);

            // Create self-destroying batch file that will delete this program's binaries
            Console.WriteLine("Creating self-destruct batch file...");
            var programPath = string.Format("{0}CodeReleasePreparer{1}", Paths.Root, Path.DirectorySeparatorChar);
            RunBatchFile(true, "CHOICE /c 1 /d 1 /t 2 > nul", "RMDIR /S /Q \"" + programPath + "bin\"",
                         "RMDIR /S /Q \"" + programPath + "obj\"", "DEL %0");

            Console.WriteLine("Done");
        }