/// <summary> /// Load all github tags in the background. /// </summary> private void LoadData() { // // Initialize the LocalDb service only once. // if (localDb == null) { var provider = new SqlLocalDbProvider(); SqlLocalDbInstance instance; try { // // If we find an existing instance then shut it down and delete it. // instance = provider.GetInstance("RockLauncher"); if (instance.IsRunning) { instance.Stop(); } SqlLocalDbInstance.Delete(instance); } finally { // // Create a new instance and keep a reference to it. // localDb = provider.CreateInstance("RockLauncher"); localDb.Start(); } } // // Load all the instances from the file system. // var instances = Directory.GetDirectories(Support.GetInstancesPath()) .Select(d => Path.GetFileName(d)).ToList(); // // Convert pre-1.0 instance folders to 1.0 instance folders, which contain a // RockWeb for the current instance data. // foreach (string instance in instances) { string instancePath = Path.Combine(Support.GetInstancesPath(), instance); string rockwebPath = Path.Combine(instancePath, "RockWeb"); if (!Directory.Exists(rockwebPath)) { Directory.CreateDirectory(rockwebPath); foreach (var d in Directory.GetDirectories(instancePath)) { if (!Path.GetFileName(d).Equals("RockWeb", StringComparison.CurrentCultureIgnoreCase)) { Directory.Move(d, Path.Combine(rockwebPath, Path.GetFileName(d))); } } foreach (var f in Directory.GetFiles(instancePath)) { Directory.Move(f, Path.Combine(rockwebPath, Path.GetFileName(f))); } } } // // Update the UI with the new list of instances. // Dispatcher.Invoke(() => { cbInstances.ItemsSource = instances; if (instances.Count > 0) { cbInstances.SelectedIndex = 0; } txtStatus.Text = "Idle"; UpdateState(); }); }
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(); }