/// <summary> Cleans the default repository from user files ('resharper', '.user', etc.). </summary> private static void CleanDefaultRepository() { 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); } } }
/// <summary> /// Builds projects. /// In addition runs UnitTest for testing projects. /// </summary> private static Project[] BuildProjects(out FileVersionInfo apiVersion, out Project[] allProjects) { CommandLine.WriteLine("{{white}} ======================================="); CommandLine.WriteLine("{{white}} Building the Projects"); CommandLine.WriteLine("{{white}} ======================================="); var projects = new List <Project>(); Project baseApi = new Project(Default.Combine("Src", "GoogleApis", "GoogleApis.csproj")); Project fullProfileApi = new Project(Default.Combine("Src", "GoogleApis.FullProfile", "GoogleApis.FullProfile.csproj")); Project codegen = new Project(Default.Combine("Src", "GoogleApis.Tools.CodeGen", "GoogleApis.Tools.CodeGen.csproj")); Project oauth2 = new Project(Default.Combine("Src", "GoogleApis.Authentication.OAuth2", "GoogleApis.Authentication.OAuth2.csproj")); Project generator = new Project(Default.Combine("GoogleApis.Tools.ServiceGenerator", "GoogleApis.Tools.ServiceGenerator.csproj")); var releaseProjects = new[] { baseApi, fullProfileApi, codegen, oauth2, generator }; projects.AddRange(releaseProjects); projects.Add(new Project(Default.Combine("Src", "GoogleApis.Tests.Utility", "GoogleApis.Tests.Utility.csproj"))); projects.Add(new Project(Default.Combine("Src", "GoogleApis.Tests", "GoogleApis.Tests.csproj"))); projects.Add(new Project(Default.Combine("Src", "GoogleApis.Tools.CodeGen.Tests", "GoogleApis.Tools.CodeGen.Tests.csproj"))); projects.Add(new Project(Default.Combine("Src", "GoogleApis.Authentication.OAuth2.Tests", "GoogleApis.Authentication.OAuth2.Tests.csproj"))); projects.Add(new Project(Default.Combine("GoogleApis.Tools.CodeGen.IntegrationTests", "GoogleApis.Tools.CodeGen.IntegrationTests.csproj"))); foreach (Project proj in projects) { proj.ReplaceVersion(Arguments.Version); proj.RunBuildTask(); if (!releaseProjects.Contains(proj)) // If this assembly may contain tests, then run them. { RunUnitTest(proj.BinaryFile); } } CommandLine.WriteLine(); apiVersion = FileVersionInfo.GetVersionInfo(baseApi.BinaryFile); allProjects = projects.ToArray(); return(releaseProjects); }
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(); }