Ejemplo n.º 1
0
        private void btnPackageFile_Click(object sender, EventArgs e)
        {
            try
            {
                if (FlushMetadata())
                {
                    using (var dialog = new SaveFileDialog())
                    {
                        if (!string.IsNullOrEmpty(_wizard.InstallScript.Title))
                        {
                            dialog.FileName = _wizard.InstallScript.Title + ".innpkg";
                        }
                        dialog.Filter = "Innovator Package (Single file)|*.innpkg|Innovator Package (Multiple files: for development)|*.innpkg|Manifest (Backwards compatible)|*.mf";
                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            ProgressDialog.Display(this, (d) =>
                            {
                                switch (dialog.FilterIndex)
                                {
                                case 2:
                                    var pkgFolder = new DirectoryPackage(dialog.FileName);
                                    if (!_wizard.InstallScript.Created.HasValue)
                                    {
                                        _wizard.InstallScript.Created = DateTime.Now;
                                    }
                                    _wizard.InstallScript.Modified = DateTime.Now;
                                    pkgFolder.Write(_wizard.InstallScript);
                                    break;

                                case 3:
                                    var manifest = new ManifestFolder(dialog.FileName);
                                    manifest.Write(_wizard.InstallScript);
                                    break;

                                default:
                                    using (var pkgFile = new ZipPackage(dialog.FileName))
                                    {
                                        if (!_wizard.InstallScript.Created.HasValue)
                                        {
                                            _wizard.InstallScript.Created = DateTime.Now;
                                        }
                                        _wizard.InstallScript.Modified = DateTime.Now;
                                        pkgFile.Write(_wizard.InstallScript);
                                    }
                                    break;
                                }
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HandleError(ex);
            }
        }
Ejemplo n.º 2
0
        public static void WritePackage(ConsoleTask console, InstallScript script, string output, bool multipleDirectories, bool cleanOutput)
        {
            multipleDirectories = multipleDirectories || string.Equals(Path.GetExtension(output), ".mf", StringComparison.OrdinalIgnoreCase);

            if (cleanOutput)
            {
                console.Write("Cleaning output... ");
                if (multipleDirectories)
                {
                    var dir = new DirectoryInfo(Path.GetDirectoryName(output));
                    if (dir.Exists)
                    {
                        Parallel.ForEach(dir.EnumerateFileSystemInfos(), fs =>
                        {
                            if (fs is DirectoryInfo di)
                            {
                                di.Delete(true);
                            }
                            else
                            {
                                fs.Delete();
                            }
                        });
                    }
                    else
                    {
                        dir.Create();
                    }
                }
                else
                {
                    File.Delete(output);
                }
                console.WriteLine("Done.");
            }

            console.Write("Writing package... ");
            var outputDir = Path.GetDirectoryName(output);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            switch (Path.GetExtension(output).ToLowerInvariant())
            {
            case ".mf":
                var manifest = new ManifestFolder(output);
                manifest.Write(script);
                break;

            case ".innpkg":
                if (multipleDirectories)
                {
                    using (var pkgFolder = new InnovatorPackageFolder(output))
                        pkgFolder.Write(script);
                }
                else
                {
                    if (File.Exists(output))
                    {
                        File.Delete(output);
                    }
                    using (var pkgFile = new InnovatorPackageFile(output))
                        pkgFile.Write(script);
                }
                break;

            default:
                throw new NotSupportedException("Output file type is not supported");
            }
            console.WriteLine("Done.");
        }
Ejemplo n.º 3
0
 private void btnPackageFile_Click(object sender, EventArgs e)
 {
   try
   {
     if (FlushMetadata())
     {
       using (var dialog = new SaveFileDialog())
       {
         if (!string.IsNullOrEmpty(_wizard.InstallScript.Title))
         {
           dialog.FileName = _wizard.InstallScript.Title + ".innpkg";
         }
         dialog.Filter = "Innovator Package (Single file)|*.innpkg|Innovator Package (Multiple files: for development)|*.innpkg|Manifest (Backwards compatible)|*.mf";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
           ProgressDialog.Display(this, () =>
           {
             switch (dialog.FilterIndex)
             {
               case 2:
                 var pkgFolder = new InnovatorPackageFolder(dialog.FileName);
                 if (!_wizard.InstallScript.Created.HasValue) _wizard.InstallScript.Created = DateTime.Now;
                 _wizard.InstallScript.Modified = DateTime.Now;
                 pkgFolder.Write(_wizard.InstallScript);
                 break;
               case 3:
                 var manifest = new ManifestFolder(dialog.FileName);
                 manifest.Write(_wizard.InstallScript);
                 break;
               default:
                 using (var pkgFile = new InnovatorPackageFile(dialog.FileName))
                 {
                   if (!_wizard.InstallScript.Created.HasValue) _wizard.InstallScript.Created = DateTime.Now;
                   _wizard.InstallScript.Modified = DateTime.Now;
                   pkgFile.Write(_wizard.InstallScript);
                 }
                 break;
             }
           });
         }
       }
     }
   }
   catch (Exception ex)
   {
     Utils.HandleError(ex);
   }
 }