private void menuDeleteWixModule_Click(object sender, EventArgs e) { foreach (ListViewItem item in wixModulesList.SelectedItems) { WixModule wm = (WixModule)item.Tag; currentProject.projectWixModules.Remove(wm); } ReloadWixModuleList(); }
private void menuEditWixModule_Click(object sender, EventArgs e) { if (wixModulesList.SelectedItems.Count != 1) { return; } WixModule wm = (WixModule)wixModulesList.SelectedItems[0].Tag; Shell.Browse(wm.Path); }
private void menuCompileWixModule_Click(object sender, EventArgs e) { compilerOutput.Text = ""; if (wixModulesList.SelectedItems.Count != 1) { return; } WixModule wm = (WixModule)wixModulesList.SelectedItems[0].Tag; if (CurrentProject.CompileWixModule(wm)) { MessageBox.Show("Compilation of \"" + wm.Name + "\" completed OK"); } }
private void addWixModuleMenu_Click(object sender, EventArgs e) { // Open file-dialog OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; dlg.InitialDirectory = LastSelectedFolder; dlg.RestoreDirectory = true; dlg.Filter = "Wix source-files (*.wxs)|*.wxs|Wix object-files (*.wixobj)|*.wixobj|All files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { foreach (string file in dlg.FileNames) { try { string my_file = currentProject.projectProperties.UseRelativePaths ? Shell.GetRelativePath(file) : file; string extension = Path.GetExtension(my_file).ToLower(); if ((extension != ".wxs") && (extension != ".wixobj")) { throw new ApplicationException( "The Wix-module \"" + my_file + "\" must have extension \".wxs\" or \".wixobj.\""); } WixModule wix = new WixModule(); wix.Path = my_file; wix.GetInfo(); currentProject.projectWixModules.Add(wix); } catch (Exception ex) { MessageBox.Show("Failed to add the wix-module: \"" + file + "\".\r\n" + ex.Message); break; } } ReloadWixModuleList(); } }
private void wixModulesList_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { try { string my_file = currentProject.projectProperties.UseRelativePaths ? Shell.GetRelativePath(file) : file; string extension = Path.GetExtension(my_file).ToLower(); if ((extension != ".wxs") && (extension != ".wixobj")) { throw new ApplicationException( "The Wix-module \"" + my_file + "\" must have extension \".wix\" or \".wixobj.\""); } WixModule wix = new WixModule(); wix.Path = my_file; wix.GetInfo(); currentProject.projectWixModules.Add(wix); } catch (Exception ex) { MessageBox.Show("Failed to add the wix-module: \"" + file + "\".\r\n" + ex.Message); break; } } ReloadWixModuleList(); }
private bool CompileWixModuleIfRequired(WixModule wm) { switch (wm.Compile) { case WixModule.CompileModeE.Auto: if (Path.GetExtension(wm.Path) != ".wxs") return true; // Source is not the source-file if (File.GetLastWriteTime(wm.SrcPath) <= File.GetLastWriteTime(wm.DstPath)) return true; // No need to compile break; case WixModule.CompileModeE.Yes: break; case WixModule.CompileModeE.No: return true; } return CompileWixModule(wm); }
public bool CompileWixModule(WixModule wm) { string cmd = ""; if (!File.Exists(wm.SrcPath)) { MessageBox.Show("The file \"" + wm.SrcPath + "\" does not exist!"); return false; } try { List<string> args = new List<string>(); cmd = Shell.GetWixBinary("candle.exe"); args.Add(wm.SrcPath); if (!isMergeModle) { args.Add("-ext"); args.Add(Shell.GetWixBinary("WixUIExtension.dll")); } args.Add("-out"); args.Add(wm.DstPath); if (!Shell.Execute(cmd, args)) { MessageBox.Show("Compilation failed. See the Output tab for details."); return false; } } catch (Exception ex) { MessageBox.Show("\"" + cmd + "\"\r\nFailed with an exception: \r\n" + ex.ToString()); return false; } return true; }