/// <summary> /// Download the tag-release from the GitHub URL and build it. /// </summary> /// <param name="url">The URL that contains the Zip archive of the release.</param> /// <param name="devenv">The Visual Studio executable to use when building.</param> /// <param name="template">What to name the template after it has been built.</param> public void DownloadRelease(string url, string devenv, string template) { TemplateName = template; DevEnvExecutable = devenv; string filename = Path.Combine(Support.GetDataPath(), "temp.zip"); UpdateStatusText("Downloading..."); var webClient = new WebClient(); webClient.Headers.Add("User-Agent", "RockDevBooster"); webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged; webClient.DownloadFileCompleted += WebClient_DownloadFileCompleted; webClient.DownloadFileAsync(new Uri(url), filename); }
/// <summary> /// Notification that the download has completed. Check for error and continue the operation. /// </summary> /// <param name="sender">The object that sent this event.</param> /// <param name="e">The arguments that describe this event.</param> private void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { // // Check if there was an error downloading. // if (e.Error != null) { UpdateStatusText(e.Error.Message); BuildCompleted?.Invoke(this, new EventArgs()); return; } // // Start the unpack process. // UnpackRelease(Path.Combine(Support.GetDataPath(), "temp.zip")); }
/// <summary> /// Compress the RockWeb folder into a ZIP file as a template. Then do final cleanup. /// </summary> private void BuildTemplate() { // // Compress the RockWeb folder into a template ZIP file. // UpdateStatusText("Compressing RockWeb..."); var zipFile = Path.Combine(Support.GetTemplatesPath(), TemplateName + ".zip"); var rockWeb = Path.Combine(Support.GetBuildPath(), "RockWeb"); Support.CreateZipFromFolder(zipFile, rockWeb); // // Cleanup temporary files. // UpdateStatusText("Cleaning up..."); Directory.Delete(Support.GetBuildPath(), true); string tempfilename = Path.Combine(Support.GetDataPath(), "temp.zip"); File.Delete(tempfilename); UpdateStatusText("Template has been created."); BuildCompleted?.Invoke(this, new EventArgs()); }