BuildRelease.Program.Main C# (CSharp) Method

Main() private method

private Main ( string args ) : void
args string
return void
        static void Main(string[] args)
        {
            // Try to enlarge the window.
            try
            {
                Console.SetWindowSize(Console.LargestWindowWidth * 8 / 9, Console.LargestWindowHeight * 8 / 9);
            } catch (Exception) {}

            // Create the name of the local working copy.
            string workingCopy = DateTime.UtcNow.ToString("d", CultureInfo.CreateSpecificCulture("en-US")).Replace('/', '-');
            string fullPath = Path.GetFullPath(workingCopy);
            if (!Directory.Exists(fullPath))
            {
                Directory.CreateDirectory(fullPath);
            }

            Environment.CurrentDirectory = WorkingCopy = fullPath;
            CommandLine.DisplayGoogleSampleHeader("Release Builder: "+workingCopy);
            CommandLine.EnableExceptionHandling();

            // Parse command line arguments.
            CommandLine.ParseArguments(Arguments = new CommandLineArguments(), args);

            // 1. Create the local repositories.
            CheckoutRepositories();

            // Clean up the default/ repository by removing cache-files.
            string toDelete = Default.Combine("_ReSharper.GoogleApisClient");
            if (Directory.Exists(toDelete))
            {
                Directory.Delete(toDelete, true);
            }
            foreach (string pattern in new[] { "*.dotcover", "*.user", "*.suo" })
            {
                foreach (string file in Directory.GetFiles(Default.WorkingDirectory, pattern))
                {
                    File.Delete(file);
                }
            }

            // 2. Create the project/build tasks.
            FileVersionInfo apiVersion;
            Project[] allProjects;
            Project[] baseLibrary = BuildProjects(out apiVersion, out allProjects);
            Project servicegen = baseLibrary.Where(proj => proj.Name == "GoogleApis.Tools.ServiceGenerator").Single();

            // Retrieve tag name.
            string tag = GetTagName(apiVersion);

            if (Arguments.IsStableRelease)
            {
                UpdateSamples(baseLibrary, servicegen);
            }

            // 4. Build contrib.
            string notes = CreateChangelog(tag);
            string zipDir;
            notes = BuildContribRelease(tag, notes, baseLibrary, allProjects, servicegen, out zipDir);

            // 5. Update the Wiki.
            if (Arguments.IsStableRelease)
            {
                UpdateWiki(notes, zipDir);
            }

            // Ask the user whether he wants to continue the release.
            string res = "no";
            CommandLine.WriteLine("{{white}} =======================================");
            CommandLine.WriteResult("Version: ", apiVersion.ProductVersion);
            CommandLine.WriteLine();

            if (Arguments.UseLocalRepository)
            {
                CommandLine.WriteAction("Local build done.");
                CommandLine.PressAnyKeyToExit();
                return;
            }

            // 6. Commit & tag the release
            CommitAndTagRelease(tag);

            CommandLine.WriteLine("   {{gray}}In the next step all changes will be commited and tagged.");
            CommandLine.WriteLine("   {{gray}}Only continue when you are sure that you don't have to make any new changes.");
            CommandLine.RequestUserInput("Do you want to continue with the release? Type YES.", ref res);
            CommandLine.WriteLine();
            if (res == "YES")
            {
                // Check for incoming changes
                foreach (Hg repository in AllRepositories)
                {
                    if (repository.HasIncomingChanges)
                    {
                        CommandLine.WriteError(
                            "Repository [{0}] has incoming changes. Run hg pull & update first!", repository.Name);
                        CommandLine.PressAnyKeyToExit();
                        return;
                    }
                }

                // 7. Push
                PushChanges();
            }
            CommandLine.PressAnyKeyToExit();
        }