/// <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()); }
protected void BuildPackage() { txtStatus.Text = "Packaging..."; var pluginJson = File.ReadAllText(Path.Combine(ProjectPath, "rockplugin.json")); var pluginInfo = JsonConvert.DeserializeObject <PluginFormat.Plugin>(pluginJson); var stagingPath = Path.Combine(Path.Combine(ProjectPath, "obj"), "_Package"); var contentPath = Path.Combine(stagingPath, "content"); var installPath = Path.Combine(stagingPath, "install"); var uninstallPath = Path.Combine(stagingPath, "uninstall"); pluginInfo.ConfigureDefaults(); var saveFileDialog = new SaveFileDialog(); saveFileDialog.DereferenceLinks = false; saveFileDialog.FileName = pluginInfo.Name.Replace(" ", "") + ".plugin"; saveFileDialog.DefaultExt = "plugin"; saveFileDialog.Filter = "Plugin Files (*.plugin)|*.plugin"; if (saveFileDialog.ShowDialog() == false) { txtStatus.Text = "Cancelled"; UpdateState(); return; } string pluginFileName = saveFileDialog.FileName; if (Directory.Exists(stagingPath)) { Directory.Delete(stagingPath, true); } Directory.CreateDirectory(stagingPath); Directory.CreateDirectory(contentPath); Directory.CreateDirectory(installPath); Directory.CreateDirectory(uninstallPath); // // Copy the Controls, Themes, Webhooks. // CopyFiles(CombinePaths(ProjectPath, pluginInfo.ControlsPath), CombinePaths(contentPath, pluginInfo.PluginPath)); CopyFiles(CombinePaths(ProjectPath, pluginInfo.ThemesPath), CombinePaths(contentPath, "Themes")); CopyFiles(CombinePaths(ProjectPath, pluginInfo.WebhooksPath), CombinePaths(contentPath, "Webhooks")); // // Copy DLLs. // var dlls = GetFileList(Path.Combine(ProjectPath, "obj", "Release")) .Select(f => Path.GetFileName(f)) .Where(f => f.EndsWith(".dll")) .ToList(); dlls.AddRange(pluginInfo.DLLs); CopyDLLs(dlls, Path.Combine(contentPath, "bin")); // // Copy the SQL scripts. // if (!string.IsNullOrWhiteSpace(pluginInfo.InstallSql)) { File.Copy(CombinePaths(ProjectPath, pluginInfo.InstallSql), Path.Combine(installPath, "run.sql")); } if (!string.IsNullOrWhiteSpace(pluginInfo.UninstallSql)) { File.Copy(CombinePaths(ProjectPath, pluginInfo.UninstallSql), Path.Combine(uninstallPath, "run.sql")); } // // Copy any additional files. // foreach (var file in pluginInfo.Copy) { File.Copy(CombinePaths(ProjectPath, file.Source), CombinePaths(contentPath, file.Destination)); } // // Build the install deletefile.lst. // var files = pluginInfo.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(pluginInfo.RemoveFilesOnUninstall.Select(f => f.Replace("/", "\\"))); File.WriteAllLines(Path.Combine(uninstallPath, "deletefile.lst"), files.ToArray()); // // Zip it all up. // Support.CreateZipFromFolder(pluginFileName, stagingPath); txtStatus.Text = "Package Built."; UpdateState(); }