/// <summary> /// Delete the selected instance from disk. /// </summary> /// <param name="sender">The object that is sending this event.</param> /// <param name="e">The arguments that describe the event.</param> private void btnMakeTemplate_Click(object sender, RoutedEventArgs e) { var textInputDialog = new Dialogs.TextInputDialog(this, "Template Name"); if (!textInputDialog.ShowDialog() ?? false) { return; } var templateName = textInputDialog.Text; // // Check if this template already exists. // if (File.Exists(Path.Combine(Support.GetTemplatesPath(), templateName + ".zip"))) { MessageBox.Show("A template with the name " + templateName + " already exists.", "Cannot make template", MessageBoxButton.OK, MessageBoxImage.Hand); return; } // // Compress the RockWeb folder into a template ZIP file. // var zipFile = Path.Combine(Support.GetTemplatesPath(), templateName + ".zip"); var items = (List <string>)cbInstances.ItemsSource; var path = Path.Combine(Support.GetInstancesPath(), items[cbInstances.SelectedIndex], "RockWeb"); Support.CreateZipFromFolder(zipFile, path); TemplatesView.UpdateTemplates(); }
/// <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()); }
/// <summary> /// Build a package from all the components available. /// </summary> protected void BuildPackage() { txtStatus.Text = "Packaging..."; // // Get all our staging paths. // var stagingPath = Support.GetPackageBuildPath(); var contentPath = Path.Combine(stagingPath, "content"); var installPath = Path.Combine(stagingPath, "install"); var uninstallPath = Path.Combine(stagingPath, "uninstall"); // // Get the filename the user wants to save the plugin into. // var saveFileDialog = new SaveFileDialog(); saveFileDialog.DereferenceLinks = false; saveFileDialog.FileName = Plugin.Name.Replace(" ", "") + ".plugin"; saveFileDialog.DefaultExt = "plugin"; saveFileDialog.Filter = "Plugin Files (*.plugin)|*.plugin|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialog() == false) { txtStatus.Text = "Cancelled"; UpdateState(); return; } string pluginFileName = saveFileDialog.FileName; txtConsole.AppendText(string.Format("\nBuilding package \"{0}\"\n", pluginFileName)); txtConsole.ScrollToEnd(); // // Delete any failed builds. // if (Directory.Exists(stagingPath)) { Directory.Delete(stagingPath, true); } // // Create all our staging paths. // Directory.CreateDirectory(stagingPath); Directory.CreateDirectory(contentPath); Directory.CreateDirectory(installPath); Directory.CreateDirectory(uninstallPath); // // Copy the Controls, Themes, Webhooks. // CopyFiles(GetPluginRelativePath(Plugin, Plugin.ControlsPath), CombinePaths(contentPath, Plugin.PluginPath, Plugin)); CopyFiles(GetPluginRelativePath(Plugin, Plugin.ThemesPath), CombinePaths(contentPath, "Themes", null)); CopyFiles(GetPluginRelativePath(Plugin, Plugin.WebhooksPath), CombinePaths(contentPath, "Webhooks", null)); // // Copy DLLs. // string projectFile = GetPluginRelativePath(Plugin, Plugin.ProjectFile); if (File.Exists(projectFile)) { var dlls = GetFileList(Path.Combine(PluginPath, "obj", "Release")) .Select(f => Path.GetFileName(f)) .Where(f => f.EndsWith(".dll")) .ToList(); dlls.AddRange(Plugin.DLLs); CopyDLLs(Path.GetDirectoryName(GetPluginRelativePath(Plugin, Plugin.ProjectFile)), dlls, Path.Combine(contentPath, "bin")); } // // Copy the SQL scripts. // if (!string.IsNullOrWhiteSpace(Plugin.InstallSql)) { CopyFile(GetPluginRelativePath(Plugin, Plugin.InstallSql), Path.Combine(installPath, "run.sql")); } if (!string.IsNullOrWhiteSpace(Plugin.UninstallSql)) { CopyFile(GetPluginRelativePath(Plugin, Plugin.UninstallSql), Path.Combine(uninstallPath, "run.sql")); } // // Copy any additional files. // foreach (var file in Plugin.Copy) { CopyFile(GetPluginRelativePath(Plugin, file.Source), CombinePaths(contentPath, file.Destination, Plugin)); } // // Build the install deletefile.lst. // var files = Plugin.RemoveFilesOnInstall.Select(f => f.Replace("/", "\\")).ToList(); File.WriteAllLines(Path.Combine(installPath, "deletefile.lst"), files.ToArray()); // // Build the uninstall deletefile.lst. // string stripPath = string.Format("{0}\\", contentPath); files = GetFileList(contentPath).Select(f => f.Replace(stripPath, string.Empty)).ToList(); files.AddRange(Plugin.RemoveFilesOnUninstall.Select(f => f.Replace("/", "\\"))); File.WriteAllLines(Path.Combine(uninstallPath, "deletefile.lst"), files.ToArray()); // // Zip it all up. // txtConsole.AppendText("Compressing zip file\n"); txtConsole.ScrollToEnd(); Support.CreateZipFromFolder(pluginFileName, stagingPath); txtStatus.Text = "Package Built."; UpdateState(); }