private void addFilesMenu_Click(object sender, EventArgs e) { SetupFeature feature = null; try { feature = (SetupFeature)featuresTree.SelectedNode.Tag; } catch (NullReferenceException) { return; } // Open file-dialog OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { // Add the target-files string[] files = dlg.FileNames; foreach (string file in files) { string my_file = currentProject.projectProperties.UseRelativePaths ? Shell.GetRelativePath(file) : file; SetupFile sf = feature.AddFile(my_file); } // Reload the file-list ReloadFileList(); } }
private void fileList_DragDrop(object sender, DragEventArgs e) { // Find the selcted feature SetupFeature feature = null; try { feature = (SetupFeature)featuresTree.SelectedNode.Tag; } catch (NullReferenceException) { return; } string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { string my_file = currentProject.projectProperties.UseRelativePaths ? Shell.GetRelativePath(file) : file; SetupFile sf = feature.AddFile(my_file); } // Reload the file-list ReloadFileList(); }
public SetupFile AddFile(string path) { SetupFile file = new SetupFile(); file.srcName = Path.GetFileName(path); file.srcDirectory = Path.GetDirectoryName(path); file.dstName = file.srcName; // Create a component SetupComponent component = new SetupComponent(); component.componentFiles.Add(file); components.Add(component); // Return the file return(file); }
/* Add one or more components to the components list, based on the contents */ /* Return true if files were added at any sublevel */ public bool MakeComponents(List <SetupComponent> components, string srcDirectory, string targetDirectory) { bool rval = false; // For now, we use one component per directory SetupComponent component = new SetupComponent(); component.targetDirectory = targetDirectory; components.Add(component); Regex exclude = null; if ("" != excludePatterns) { exclude = new Regex(excludePatterns); } //component.componentId = component.componentGuid = "Component_" // + GetMd5Hash(srcDirectory + "::" + targetDirectory); // Build pattern if ((null != patterns) && ("" != patterns)) { string my_pattern = patterns.Replace("\r\n", ""); Regex regex = new Regex(my_pattern); // Add files foreach (string path in Directory.GetFiles(srcDirectory)) { FileAttributes attr = File.GetAttributes(path); if ((attr & (FileAttributes.Device | FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary)) != 0) { // Don't use } else { if ((null != exclude) && exclude.Match(path).Success) { continue; } if (regex.Match(Path.GetFileName(path)).Success) { SetupFile file = new SetupFile(); file.srcDirectory = Path.GetDirectoryName(path); file.srcName = Path.GetFileName(path); file.dstName = file.srcName; //file.fileId = "ID_" + GetMd5Hash(path + "::" // + Path.Combine(file.dstDirectory, file.dstName)); component.componentFiles.Add(file); rval = true; } } } } // Recurse if (recurse) { foreach (string path in Directory.GetDirectories(srcDirectory)) { FileAttributes attr = File.GetAttributes(path); if ((attr & (FileAttributes.Device | FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary)) != 0) { // Dont use } else if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if ((null != exclude) && (exclude.Match(path + @"\").Success)) { continue; // Excluded } bool probe = MakeComponents(components, Path.Combine(srcDirectory, Path.GetFileName(path)), Path.Combine(targetDirectory, Path.GetFileName(path))); if (!rval && probe) { rval = true; // We found files } } } } component.addToCreateFolder = true; if (preventEmptyDirectories && !rval) { components.Remove(component); // Prevent empty dirs/structures } return(rval); }
private void AddShortcut(SetupFile file, XmlElement feature, XmlElement target, XmlElement parentDir) { AddShortcut(file.fileId, target.GetAttribute("Id"), file.menuName, file.shortcutCommandArguments, file.shortcutDescription, file.shortcutWorkingDirectory, feature, parentDir); }
private XmlElement AddShortcut(SetupFile file, XmlElement target, string shortcutType) { XmlElement shortcut = doc.CreateElement("Shortcut"); shortcut.SetAttribute("Id", shortcutType + "_shortcut_" + file.fileId); shortcut.SetAttribute("Directory", target.GetAttribute("Id")); SetNameAttribute(shortcut, file.menuName); if ("" != file.shortcutCommandArguments) shortcut.SetAttribute("Arguments", file.shortcutCommandArguments); if ("" != file.shortcutDescription) shortcut.SetAttribute("Description", file.shortcutDescription); if ("" != file.shortcutWorkingDirectory) { TargetDir dir = GetDirectoryNode(file.shortcutWorkingDirectory, null); string id = dir.mXmlNode.GetAttribute("Id"); shortcut.SetAttribute("WorkingDirectory", id); } return shortcut; }
private void AddExecuteOnInstall(SetupFile file) { if (null != this.product) { string id = GetUniqueId().ToUpper(); XmlElement p1 = doc.CreateElement("CustomAction"); p1.SetAttribute("Id", id); p1.SetAttribute("FileKey", file.fileId); p1.SetAttribute("ExeCommand", file.ExecuteOnInstallParameters); p1.SetAttribute("Execute", "immediate"); p1.SetAttribute("Return", "asyncNoWait"); this.product.AppendChild(p1); if (null != _install_execute_sequence) { XmlElement p2 = doc.CreateElement("Custom"); p2.SetAttribute("Action", id); p2.SetAttribute("After", "InstallFinalize"); _install_execute_sequence.AppendChild(p2); } } }
public SetupFile AddFile(string path) { SetupFile file = new SetupFile(); file.srcName = Path.GetFileName(path); file.srcDirectory = Path.GetDirectoryName(path); file.dstName = file.srcName; // Create a component SetupComponent component = new SetupComponent(); component.componentFiles.Add(file); components.Add(component); // Return the file return file; }
/* Add one or more components to the components list, based on the contents */ /* Return true if files were added at any sublevel */ public bool MakeComponents(List<SetupComponent> components, string srcDirectory, string targetDirectory) { bool rval = false; // For now, we use one component per directory SetupComponent component = new SetupComponent(); component.targetDirectory = targetDirectory; components.Add(component); Regex exclude = null; if ("" != excludePatterns) exclude = new Regex(excludePatterns); //component.componentId = component.componentGuid = "Component_" // + GetMd5Hash(srcDirectory + "::" + targetDirectory); // Build pattern if ((null != patterns) && ("" != patterns)) { string my_pattern = patterns.Replace("\r\n", ""); Regex regex = new Regex(my_pattern); // Add files foreach (string path in Directory.GetFiles(srcDirectory)) { FileAttributes attr = File.GetAttributes(path); if ((attr & (FileAttributes.Device | FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary)) != 0) { // Don't use } else { if ((null != exclude) && exclude.Match(path).Success) continue; if (regex.Match(Path.GetFileName(path)).Success) { SetupFile file = new SetupFile(); file.srcDirectory = Path.GetDirectoryName(path); file.srcName = Path.GetFileName(path); file.dstName = file.srcName; //file.fileId = "ID_" + GetMd5Hash(path + "::" // + Path.Combine(file.dstDirectory, file.dstName)); component.componentFiles.Add(file); rval = true; } } } } // Recurse if (recurse) { foreach (string path in Directory.GetDirectories(srcDirectory)) { FileAttributes attr = File.GetAttributes(path); if ((attr & (FileAttributes.Device | FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary)) != 0) { // Dont use } else if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if ((null != exclude) && (exclude.Match(path + @"\").Success)) continue; // Excluded bool probe = MakeComponents(components, Path.Combine(srcDirectory, Path.GetFileName(path)), Path.Combine(targetDirectory, Path.GetFileName(path))); if (!rval && probe) rval = true; // We found files } } } component.addToCreateFolder = true; if (preventEmptyDirectories && !rval) components.Remove(component); // Prevent empty dirs/structures return rval; }