public PackageForm(DevCenter devCenter, ScriptPackage package) { InitializeComponent(); if (package == null) throw new ArgumentNullException("Package argument cannot be null."); foreach (PackageExportOptions o in Enum.GetValues(typeof(PackageExportOptions))) { this.exportOptionComboBox.Items.Add(o); } this.package = package; this.devCenter = devCenter; this.scriptPackageBindingSource.Add(package); this.package.PropertyChanged += new PropertyChangedEventHandler(package_PropertyChanged); this.package.RootPath.PropertyChanged += new PropertyChangedEventHandler(RootPath_PropertyChanged); this.rootPathBindingSource.Add(package.RootPath); this.sourcePathBindingSource.Add(package.SourcePath); this.outputPathBindingSource.Add(package.OutputPath); this.packageFileBindingSource.Add(package.PackageFile); this.manifestFileBindingSource.Add(package.ManifestFile); this.setHelpLabelText(); this.enableControls(); }
public InstallerActionsForm(DevCenter devCenter, ScriptPackage package) { InitializeComponent(); if (package == null) throw new ArgumentNullException("Package argument cannot be null"); this.package = package; this.installerConfig = package.InstallerConfiguration; actionsComboBox.Format += new ListControlConvertEventHandler(actionsComboBox_Format); actionPropertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(actionPropertyGrid_PropertyValueChanged); if (package.RootPath.AbsolutePath == String.Empty) { PackageRootPathWarning w = new PackageRootPathWarning(); w.Dock = DockStyle.Fill; this.Controls.Remove(this.tableLayoutPanel); this.Controls.Add(w); } else { fillActionsCombobox(); fillActionsListView(); } }
/// <summary> /// Adds the resources for all InstallerActions to the zip package. /// </summary> public virtual void AddInstallerActionResources(ScriptPackage package, ScriptVersion version) { BasePath sourcePath = new BasePath(ScriptManifestTokens.Replace(package.SourcePath.AbsolutePath, package.Manifest, version)); foreach (InstallerAction action in package.InstallerConfiguration.Actions) { action.PackResources(_currentZipFile, PackageBuilder.ResourcesArchivePath, sourcePath); } }
public InstallerUIForm(DevCenter devCenter, ScriptPackage package) { InitializeComponent(); if (package == null) throw new ArgumentNullException("Package argument cannot be null."); this.package = package; if (package.RootPath.AbsolutePath == String.Empty) { PackageRootPathWarning w = new PackageRootPathWarning(); w.Dock = DockStyle.Fill; this.Controls.Remove(this.tableLayoutPanel); this.Controls.Add(w); } }
public void RelativePathTest() { ScriptPackage package = new ScriptPackage("test_package"); package.RootPath.AbsolutePath = "C:/code/test/"; package.OutputPath.AbsolutePath = "C:/code/test/test.mzp"; Assert.AreEqual("test.mzp", package.OutputPath.RelativePathComponent); Assert.AreEqual("C:/code/test/test.mzp", package.OutputPath.AbsolutePath); package.SourcePath.AbsolutePath = "C:/code/test/source/"; Assert.AreEqual("source/", package.SourcePath.RelativePathComponent); Assert.AreEqual("C:/code/test/source/", package.SourcePath.AbsolutePath); package.OutputPath.AbsolutePath = "C:/code/output/"; Assert.AreEqual("../output/", package.OutputPath.RelativePathComponent); Assert.AreEqual("C:/code/output/", package.OutputPath.AbsolutePath); package.PackageFile.AbsolutePath = "C:/code/output/test.mzp"; Assert.AreEqual("test.mzp", package.PackageFile.RelativePathComponent); Assert.AreEqual("C:/code/output/test.mzp", package.PackageFile.AbsolutePath); }
/// <summary> /// Writes a package to a file. /// </summary> /// <param name="package">The package to write.</param> /// <param name="exportOptions">The overwrite options for the write operation.</param> /// <returns></returns> public Boolean BuildAndWritePackage(ScriptPackage package, PackageExportOptions exportOptions) { //Loop through all versions. foreach (ScriptVersion version in package.Manifest.Versions) { String packagePath = ScriptManifestTokens.Replace(package.PackageFile.AbsolutePath, package.Manifest, version); if (version != package.Manifest.LatestVersion) { //Skip if only latest version should be exported. if ((exportOptions & PackageExportOptions.LatestOnly) == PackageExportOptions.LatestOnly) continue; //Skip if only the latest or non-existing should be exported. if ((exportOptions & PackageExportOptions.LatestAndNonExisting) == PackageExportOptions.LatestAndNonExisting) { if (File.Exists(packagePath)) continue; } } _currentZipFile = new ZipFile(); this.AddAssemblies(); this.AddMzpFiles(package.Manifest, version); this.AddManifest(package.Manifest, version); this.AddInstallerConfiguration(package.InstallerConfiguration); this.AddInstallerActionResources(package, version); try { _currentZipFile.Save(packagePath); } catch { return false; } } return true; }
private TreeNode addPackageToTree(ScriptPackage package, String filePath) { TreeNode tn = new TreeNode(package.Name); tn.ImageKey = tn.SelectedImageKey = "package"; tn.Tag = new TreeNodeData(package, typeof(PackageForm)); TreeNode manifestTn = new TreeNode("Manifest"); manifestTn.ImageKey = manifestTn.SelectedImageKey = "manifest"; manifestTn.Tag = new TreeNodeData(package.Manifest, typeof(ManifestForm)); tn.Nodes.Add(manifestTn); TreeNode metadataTn = new TreeNode("Metadata"); metadataTn.ImageKey = metadataTn.SelectedImageKey = "manifest_metadata"; metadataTn.Tag = new TreeNodeData(package.Manifest, typeof(ManifestMetadataForm)); manifestTn.Nodes.Add(metadataTn); TreeNode actionsTn = new TreeNode("Installer Actions"); actionsTn.ImageKey = actionsTn.SelectedImageKey = "action"; actionsTn.Tag = new TreeNodeData(package, typeof(InstallerActionsForm)); tn.Nodes.Add(actionsTn); TreeNode uiTn = new TreeNode("Installer UI"); uiTn.ImageKey = uiTn.SelectedImageKey = "dialog"; uiTn.Tag = new TreeNodeData(package, typeof(InstallerUIForm)); tn.Nodes.Add(uiTn); this.filesTree.Nodes.Add(tn); this.Files.Add(package, filePath); package.PropertyChanged += new PropertyChangedEventHandler(propertyChanged); return tn; }
private void writePackage(IPath path, ScriptPackage package) { JsonFileHandler<ScriptPackage> handler = new JsonFileHandler<ScriptPackage>(); try { handler.Write(path, package); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void newPackageButton_Click(object sender, EventArgs e) { this.switchNewButtonImageText(sender, newPackageButton_Click); ScriptPackage p = new ScriptPackage("New Package"); ScriptVersion v = new ScriptVersion(); v.ScriptPath = p.PackageFile.RelativePathComponent; p.Manifest.Versions.Add(v); TreeNode tn = addPackageToTree(p, String.Empty); tn.Expand(); this.filesTree.SelectedNode = tn; }