public ExportSolutionDialog (IMSBuildFileObject item, MSBuildFileFormat selectedFormat)
		{
			this.Build();
			
			labelNewFormat.Text = GetFormatText (item.FileFormat);
			
			formats = MSBuildFileFormat.GetSupportedFormats (item).ToArray ();
			foreach (var format in formats) {
				comboFormat.AppendText (GetFormatText (format));
			}

			int sel = Array.IndexOf (formats, selectedFormat);
			if (sel == -1) sel = 0;
			comboFormat.Active = sel;
			
			if (formats.Length < 2) {
				table.Remove (newFormatLabel);
				newFormatLabel.Destroy ();
				newFormatLabel = null;
				table.Remove (comboFormat);
				comboFormat.Destroy ();
				comboFormat = null;
			}
			
			//auto height
			folderEntry.WidthRequest = 380;
			Resize (1, 1);
			
			folderEntry.Path = item.ItemDirectory;
			UpdateControls ();
		}
        public SelectFileFormatDialog(IMSBuildFileObject item)
        {
            this.Build();
            string warning = "";

            foreach (string msg in item.FileFormat.GetCompatibilityWarnings(item))
            {
                warning += msg + "\n";
            }
            if (warning.Length > 0)
            {
                warning = warning.Substring(0, warning.Length - 1);
            }

            labelWarnings.Text      = warning;
            labelMessage.Text       = string.Format(labelMessage.Text, item.Name);
            labelCurrentFormat.Text = item.FileFormat.Name;

            foreach (MSBuildFileFormat format in MSBuildFileFormat.GetSupportedFormats(item))
            {
                comboNewFormat.AppendText(format.Name);
                formats.Add(format);
            }
            comboNewFormat.Active = 0;
        }
        public override PackageBuilder[] CreateDefaultBuilders()
        {
            List <PackageBuilder> list = new List <PackageBuilder> ();

            IMSBuildFileObject root = RootSolutionItem is SolutionItem ? (IMSBuildFileObject)RootSolutionItem : (IMSBuildFileObject)RootSolutionItem.ParentSolution;

            foreach (MSBuildFileFormat format in MSBuildFileFormat.GetSupportedFormats(root))
            {
                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.GetValidFormatName(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());
        }
		public SelectFileFormatDialog (IMSBuildFileObject item)
		{
			this.Build ();
			string warning = "";
			foreach (string msg in item.FileFormat.GetCompatibilityWarnings (item))
				warning += msg + "\n";
			if (warning.Length > 0)
				warning = warning.Substring (0, warning.Length - 1);
			
			labelWarnings.Text = warning;
			labelMessage.Text = string.Format (labelMessage.Text, item.Name);
			labelCurrentFormat.Text = item.FileFormat.Name;
			
			foreach (MSBuildFileFormat format in MSBuildFileFormat.GetSupportedFormats (item)) {
				comboNewFormat.AppendText (format.Name);
				formats.Add (format);
			}
			comboNewFormat.Active = 0;
		}
示例#5
0
        public async Task <string> Export(ProgressMonitor monitor, string rootSourceFile, string[] includedChildIds, string targetPath, MSBuildFileFormat format)
        {
            IMSBuildFileObject obj = null;

            if (IsWorkspaceItemFile(rootSourceFile))
            {
                obj = (await ReadWorkspaceItem(monitor, rootSourceFile)) as IMSBuildFileObject;
            }
            else if (IsSolutionItemFile(rootSourceFile))
            {
                obj = await ReadSolutionItem(monitor, rootSourceFile);
            }
            if (obj == null)
            {
                throw new InvalidOperationException("File is not a solution or project.");
            }
            using (obj) {
                return(await Export(monitor, obj, includedChildIds, targetPath, format));
            }
        }
        public ExportSolutionDialog(IMSBuildFileObject item, MSBuildFileFormat selectedFormat)
        {
            this.Build();

            labelNewFormat.Text = selectedFormat.ProductDescription;

            formats = MSBuildFileFormat.GetSupportedFormats(item).ToArray();
            foreach (var format in formats)
            {
                comboFormat.AppendText(format.ProductDescription);
            }

            int sel = Array.IndexOf(formats, selectedFormat);

            if (sel == -1)
            {
                sel = 0;
            }
            comboFormat.Active = sel;

            if (formats.Length < 2)
            {
                table.Remove(newFormatLabel);
                newFormatLabel.Destroy();
                newFormatLabel = null;
                table.Remove(comboFormat);
                comboFormat.Destroy();
                comboFormat = null;
            }

            //auto height
            folderEntry.WidthRequest = 380;
            Resize(1, 1);

            folderEntry.Path = item.ItemDirectory;
            UpdateControls();
        }
		bool SelectValidFileFormat (IMSBuildFileObject item)
		{
			var dlg = new SelectFileFormatDialog (item);
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok && dlg.Format != null) {
					item.ConvertToFormat (dlg.Format);
					return true;
				}
				return false;
			} finally {
				dlg.Destroy ();
				dlg.Dispose ();
			}
		}
		public async void Export (IMSBuildFileObject item, MSBuildFileFormat format)
		{
			ExportSolutionDialog dlg = new ExportSolutionDialog (item, format);
			
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
					using (ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true)) {
						await Services.ProjectService.Export (monitor, item.FileName, dlg.TargetFolder, dlg.Format);
					}
				}
			} finally {
				dlg.Destroy ();
				dlg.Dispose ();
			}
		}
		public static IEnumerable<MSBuildFileFormat> GetSupportedFormats (IMSBuildFileObject targetItem)
		{
			return GetSupportedFormats ().Where (f => f.CanWriteFile (targetItem));
		}
示例#10
0
        async Task <string> Export(ProgressMonitor monitor, IMSBuildFileObject obj, string[] includedChildIds, string targetPath, MSBuildFileFormat format)
        {
            string rootSourceFile = obj.FileName;
            string sourcePath     = Path.GetFullPath(Path.GetDirectoryName(rootSourceFile));

            targetPath = Path.GetFullPath(targetPath);

            if (sourcePath != targetPath)
            {
                if (!CopyFiles(monitor, obj, obj.GetItemFiles(true), targetPath, true))
                {
                    return(null);
                }

                string newFile = Path.Combine(targetPath, Path.GetFileName(rootSourceFile));
                if (IsWorkspaceItemFile(rootSourceFile))
                {
                    obj = (Solution) await ReadWorkspaceItem(monitor, newFile);
                }
                else
                {
                    obj = await ReadSolutionItem(monitor, newFile);
                }

                using (obj) {
                    var oldFiles = obj.GetItemFiles(true).ToList();
                    ExcludeEntries(obj, includedChildIds);
                    if (format != null)
                    {
                        obj.ConvertToFormat(format);
                    }
                    await obj.SaveAsync(monitor);

                    var newFiles           = obj.GetItemFiles(true);
                    var resolvedTargetPath = new FilePath(targetPath).ResolveLinks().FullPath;

                    foreach (FilePath f in newFiles)
                    {
                        if (!f.IsChildPathOf(resolvedTargetPath))
                        {
                            if (obj is Solution)
                            {
                                monitor.ReportError(GettextCatalog.GetString("The solution '{0}' is referencing the file '{1}' which is located outside the root solution directory.", obj.Name, f.FileName), null);
                            }
                            else
                            {
                                monitor.ReportError(GettextCatalog.GetString("The project '{0}' is referencing the file '{1}' which is located outside the project directory.", obj.Name, f.FileName), null);
                            }
                        }
                        oldFiles.Remove(f);
                    }

                    // Remove old files
                    foreach (FilePath file in oldFiles)
                    {
                        if (File.Exists(file))
                        {
                            File.Delete(file);

                            // Exclude empty directories
                            FilePath dir = file.ParentDirectory;
                            if (!Directory.EnumerateFileSystemEntries(dir).Any())
                            {
                                try {
                                    Directory.Delete(dir);
                                } catch (Exception ex) {
                                    monitor.ReportError(null, ex);
                                }
                            }
                        }
                    }
                    return(obj.FileName);
                }
            }
            else
            {
                using (obj) {
                    ExcludeEntries(obj, includedChildIds);
                    if (format != null)
                    {
                        obj.ConvertToFormat(format);
                    }
                    await obj.SaveAsync(monitor);

                    return(obj.FileName);
                }
            }
        }
示例#11
0
 public static IEnumerable <MSBuildFileFormat> GetSupportedFormats(IMSBuildFileObject targetItem)
 {
     return(GetSupportedFormats().Where(f => f.CanWriteFile(targetItem)));
 }
示例#12
0
		async Task<string> Export (ProgressMonitor monitor, IMSBuildFileObject obj, string[] includedChildIds, string targetPath, MSBuildFileFormat format)
		{
			string rootSourceFile = obj.FileName;
			string sourcePath = Path.GetFullPath (Path.GetDirectoryName (rootSourceFile));
			targetPath = Path.GetFullPath (targetPath);
			
			if (sourcePath != targetPath) {
				if (!CopyFiles (monitor, obj, obj.GetItemFiles (true), targetPath, true))
					return null;
				
				string newFile = Path.Combine (targetPath, Path.GetFileName (rootSourceFile));
				if (IsWorkspaceItemFile (rootSourceFile))
					obj = (Solution) await ReadWorkspaceItem (monitor, newFile);
				else
					obj = await ReadSolutionItem (monitor, newFile);
				
				using (obj) {
					var oldFiles = obj.GetItemFiles (true).ToList ();
					ExcludeEntries (obj, includedChildIds);
					if (format != null)
						obj.ConvertToFormat (format);
					await obj.SaveAsync (monitor);
					var newFiles = obj.GetItemFiles (true);
					var resolvedTargetPath = new FilePath (targetPath).ResolveLinks ().FullPath;

					foreach (FilePath f in newFiles) {
						if (!f.IsChildPathOf (resolvedTargetPath)) {
							if (obj is Solution)
								monitor.ReportError (GettextCatalog.GetString ("The solution '{0}' is referencing the file '{1}' which is located outside the root solution directory.", obj.Name, f.FileName), null);
							else
								monitor.ReportError (GettextCatalog.GetString ("The project '{0}' is referencing the file '{1}' which is located outside the project directory.", obj.Name, f.FileName), null);
						}
						oldFiles.Remove (f);
					}
	
					// Remove old files
					foreach (FilePath file in oldFiles) {
						if (File.Exists (file)) {
							File.Delete (file);
						
							// Exclude empty directories
							FilePath dir = file.ParentDirectory;
							if (Directory.GetFiles (dir).Length == 0 && Directory.GetDirectories (dir).Length == 0) {
								try {
									Directory.Delete (dir);
								} catch (Exception ex) {
									monitor.ReportError (null, ex);
								}
							}
						}
					}
					return obj.FileName;
				}
			}
			else {
				using (obj) {
					ExcludeEntries (obj, includedChildIds);
					if (format != null)
						obj.ConvertToFormat (format);
					await obj.SaveAsync (monitor);
					return obj.FileName;
				}
			}
		}