Example #1
0
        public override PackageBuilder[] CreateDefaultBuilders()
        {
            List <PackageBuilder> list = new List <PackageBuilder> ();

            foreach (FileFormat format in Services.ProjectService.FileFormats.GetFileFormatsForObject(RootSolutionItem))
            {
                SourcesZipPackageBuilder pb = (SourcesZipPackageBuilder)Clone();
                pb.FileFormat = format;

                // The suffix for the archive will be the extension of the file format.
                // If there is no extension, use the whole file name.
                string fname  = format.GetValidFileName(RootSolutionItem, RootSolutionItem.ParentSolution.FileName);
                string suffix = Path.GetExtension(fname);
                if (suffix.Length > 0)
                {
                    suffix = suffix.Substring(1).ToLower();                       // Remove the initial dot
                }
                else
                {
                    suffix = Path.GetFileNameWithoutExtension(suffix).ToLower();
                }

                // Change the name in the target file
                string ext = DeployService.GetArchiveExtension(pb.TargetFile);
                string fn  = TargetFile.Substring(0, TargetFile.Length - ext.Length);
                pb.TargetFile = fn + "-" + suffix + ext;
                list.Add(pb);
            }
            return(list.ToArray());
        }
Example #2
0
        public override void CopyFrom(PackageBuilder other)
        {
            base.CopyFrom(other);
            SourcesZipPackageBuilder builder = (SourcesZipPackageBuilder)other;

            targetFile = builder.targetFile;
            format     = builder.format;
            fileFormat = builder.fileFormat;
        }
		public SourcesZipEditorWidget (PackageBuilder target, FileFormat selectedFormat)
		{
			this.Build();
			this.target = (SourcesZipPackageBuilder) target;
			loading = true;
			
			if (target.RootSolutionItem is SolutionFolder)
				formats = Services.ProjectService.FileFormats.GetFileFormatsForObject (target.Solution);
			else
				formats = Services.ProjectService.FileFormats.GetFileFormatsForObject (target.RootSolutionItem);
			
			if (selectedFormat == null) selectedFormat = this.target.FileFormat;
			if (selectedFormat == null)
				selectedFormat = formats [0];
			
			int sel = 0;
			for (int n=0; n<formats.Length; n++) {
				comboFormat.AppendText (formats[n].Name);
				if (formats[n].Name == selectedFormat.Name)
					sel = n;
			}

			comboFormat.Active = sel;
			this.target.FileFormat = formats [sel];
			
			string[] archiveFormats = DeployService.SupportedArchiveFormats;
			int zel = 1;
			for (int n=0; n<archiveFormats.Length; n++) {
				comboZip.AppendText (archiveFormats [n]);
				if (this.target.TargetFile.EndsWith (archiveFormats [n]))
					zel = n;
			}
			
			if (!string.IsNullOrEmpty (this.target.TargetFile)) {
				string ext = archiveFormats [zel];
				folderEntry.Path = System.IO.Path.GetDirectoryName (this.target.TargetFile);
				entryZip.Text = System.IO.Path.GetFileName (this.target.TargetFile.Substring (0, this.target.TargetFile.Length - ext.Length));
				comboZip.Active = zel;
			}
			loading = false;
		}
		void RunTestSourcesPackage (string solFile)
		{
			solFile = Util.GetSampleProject (solFile);
			Solution sol = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor(), solFile);
			
			SourcesZipPackageBuilder pb = new SourcesZipPackageBuilder ();
			pb.FileFormat = sol.FileFormat;
			pb.SetSolutionItem (sol.RootFolder, sol.GetAllSolutionItems<SolutionItem> ());
			
			pb.TargetFile = GetTempTarFile ("sourceszip");
			
			if (!DeployService.BuildPackage (Util.GetMonitor (), pb))
				Assert.Fail ("Package generation failed");
			
			List<string> files = new List<string> ();
			foreach (string f in sol.GetItemFiles (true)) {
				files.Add (sol.GetRelativeChildPath (f));
			}
			CheckTarContents (pb.TargetFile, files.ToArray (), true);
		}