public virtual DeployFileCollection GetCombineDeployFiles (DeployContext ctx, SolutionFolder combine, ConfigurationSelector configuration)
		{
			if (Next != null)
				return Next.GetDeployFiles (ctx, combine, configuration);
			else
				return new DeployFileCollection ();
		}
		public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry, Widget editor)
		{
			GtkFeatureWidget fw = (GtkFeatureWidget) editor;
			ReferenceManager refmgr = new ReferenceManager ((DotNetProject) entry);
			refmgr.GtkPackageVersion = fw.SelectedVersion;
			refmgr.Dispose ();
		}
		public void Fill (SolutionFolder parentCombine, SolutionItem entry, ISolutionItemFeature[] features)
		{
			selectedFeatures.Clear ();
			selectedEditors.Clear ();
			
			this.entry = entry;
			this.parentCombine = parentCombine;
			
			foreach (Gtk.Widget w in box.Children) {
				box.Remove (w);
				w.Destroy ();
			}
			// Show enabled features at the beginning
			foreach (ISolutionItemFeature feature in features)
				if (feature.GetSupportLevel (parentCombine, entry) == FeatureSupportLevel.Enabled) {
					Gtk.Widget editor = AddFeature (feature);
					selectedFeatures.Add (feature);
					selectedEditors.Add (editor);
				}
			foreach (ISolutionItemFeature feature in features)
				if (feature.GetSupportLevel (parentCombine, entry) != FeatureSupportLevel.Enabled)
					AddFeature (feature);
			
			if (box.Children.Length == 0) {
				// No features
				Label lab = new Label ();
				lab.Xalign = 0;
				lab.Text = GettextCatalog.GetString ("There are no additional features available for this project.");
				box.PackStart (lab, false, false, 0);
				lab.Show ();
			}
			scrolled.AddWithViewport (box);
		}
예제 #4
0
        internal void AddProject(AbstractDProject sub)
        {
            var folder = sub.BaseDirectory == BaseDirectory || sub.BaseDirectory.IsChildPathOf (BaseDirectory) ? RootFolder : ExternalDepFolder;

            if (folder == ExternalDepFolder && sub is DubProject) {
                var packageName = (sub as DubProject).packageName.Split(':');
                for (int i = 0; i < packageName.Length - 1; i++) {
                    bool foundSubFolder = false;
                    foreach (var subFolder in folder.GetAllItems<SolutionFolder>()) {
                        if (String.Equals (subFolder.Name, packageName [i], StringComparison.CurrentCultureIgnoreCase)) {
                            folder = subFolder;
                            foundSubFolder = true;
                            break;
                        }
                    }
                    if (!foundSubFolder) {
                        var newSubFolder = new SolutionFolder{ Name = packageName [i] };
                        folder.AddItem (newSubFolder);
                        folder = newSubFolder;
                    }
                }
            }

            if (!folder.Items.Contains (sub))
                folder.AddItem (sub, false);
        }
		public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
		{
			if (entry is Project)
				return FeatureSupportLevel.SupportedByDefault;
			else
				return FeatureSupportLevel.NotSupported;
		}
예제 #6
0
		public void ApplyFeature (SolutionFolder parentFolder, SolutionItem entry, Gtk.Widget editor)
		{
			// The solution may not be saved yet
			if (parentFolder.ParentSolution.FileName.IsNullOrEmpty || !System.IO.File.Exists (parentFolder.ParentSolution.FileName))
				parentFolder.ParentSolution.Saved += OnSolutionSaved;
			else
				OnSolutionSaved (parentFolder.ParentSolution, null);
		}
예제 #7
0
        public void CheckProjectContainsItself()
        {
            var folder = new SolutionFolder ();
            var project = new DotNetAssemblyProject { Name = "foo" };
            folder.AddItem (project);

            Assert.IsNotNull (folder.GetProjectContainingFile (project.FileName), "#1");
        }
		public ProtobuildSubmodule (ProtobuildModuleInfo latestModuleInfo, ProtobuildModuleInfo submodule, SolutionFolder rootFolder)
        {
            parentModule = latestModuleInfo;
            currentModule = submodule;
			RootFolder = rootFolder;
			Packages = new ProtobuildPackages(this);
			Definitions = new ItemCollection<IProtobuildDefinition>();
			Submodules = new ItemCollection<ProtobuildSubmodule>();
		}
		public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
		{
			if (entry is TranslationProject && parentCombine != null)
				return FeatureSupportLevel.Enabled;
			else if ((entry is Project) && parentCombine != null)
				return FeatureSupportLevel.Supported;
			else
				return FeatureSupportLevel.NotSupported;
		}
		public static ISolutionItemFeature[] GetFeatures (SolutionFolder parentCombine, SolutionItem entry)
		{
			List<ISolutionItemFeature> list = new List<ISolutionItemFeature> ();
			foreach (ISolutionItemFeature e in AddinManager.GetExtensionObjects ("/MonoDevelop/Ide/ProjectFeatures", typeof(ISolutionItemFeature), true)) {
				FeatureSupportLevel level = e.GetSupportLevel (parentCombine, entry);
				if (level == FeatureSupportLevel.Enabled || level == FeatureSupportLevel.SupportedByDefault)
					list.Add (e);
			}
			return list.ToArray ();
		}
		public SolutionFolderTestGroup (SolutionFolder c): base (c.Name, c)
		{
			string storeId = c.ItemId;
			string resultsPath = Path.Combine (c.BaseDirectory, "test-results");
			ResultsStore = new XmlResultsStore (resultsPath, storeId);
			
			combine = c;
			combine.ItemAdded += OnEntryChanged;
			combine.ItemRemoved += OnEntryChanged;
			combine.NameChanged += OnCombineRenamed;
		}
예제 #12
0
		public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
		{
			if (!(entry is DotNetProject) || !GtkDesignInfo.SupportsRefactoring (entry as DotNetProject))
				return FeatureSupportLevel.NotSupported;
			else if (GtkDesignInfo.SupportsDesigner ((Project)entry))
				return FeatureSupportLevel.Enabled;
			else if (entry is DotNetAssemblyProject)
				return FeatureSupportLevel.SupportedByDefault;
			else
				return FeatureSupportLevel.Supported;
		}
		public SolutionFolderTestGroup (SolutionFolder c): base (c.Name, c)
		{
			string storeId = c.ItemId;
			string resultsPath = MonoDevelop.NUnit.RootTest.GetTestResultsDirectory (c.BaseDirectory);
			ResultsStore = new XmlResultsStore (resultsPath, storeId);
			
			combine = c;
			combine.ItemAdded += OnEntryChanged;
			combine.ItemRemoved += OnEntryChanged;
			combine.NameChanged += OnCombineRenamed;
		}
예제 #14
0
		public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
		{
			if (parentCombine == null)
				return FeatureSupportLevel.NotSupported;
			
			if (entry is PackagingProject)
				return FeatureSupportLevel.Enabled;
			else if (entry is Project)
				return FeatureSupportLevel.SupportedByDefault;
			else
				return FeatureSupportLevel.NotSupported;
		}
		ProjectCreateInformation CreateProjectCreateInformation (NewProjectConfiguration config, SolutionFolder parentFolder)
		{
			ProjectCreateInformation cinfo = new ProjectCreateInformation ();
			cinfo.SolutionPath = new FilePath (config.SolutionLocation).ResolveLinks ();
			cinfo.ProjectBasePath = new FilePath (config.ProjectLocation).ResolveLinks ();
			cinfo.ProjectName = config.ProjectName;
			cinfo.SolutionName = config.SolutionName;
			cinfo.ParentFolder = parentFolder;
			cinfo.ActiveConfiguration = IdeApp.Workspace.ActiveConfiguration;
			cinfo.Parameters = config.Parameters;
			return cinfo;
		}
        public static SolutionFolder AddSolutionFolder(this Solution solution, string name, params FilePath[] files)
        {
            var solutionFolder = new SolutionFolder {
                Name = name
            };

            foreach (FilePath file in files) {
                solutionFolder.Files.Add (file);
            }

            solution.RootFolder.AddItem (solutionFolder);
            return solutionFolder;
        }
		public SolutionFolderTestGroup (SolutionFolder c): base (c.Name, c)
		{
			string storeId = c.ItemId;
			string resultsPath = UnitTestService.GetTestResultsDirectory (c.BaseDirectory);
			ResultsStore = new BinaryResultsStore (resultsPath, storeId);
			
			folder = c;
			folder.NameChanged += OnCombineRenamed;

			if (c.IsRoot) {
				folder.ParentSolution.SolutionItemAdded += OnEntryChanged;
				folder.ParentSolution.SolutionItemRemoved += OnEntryChanged;
			}
		}
		ProcessedTemplateResult ProcessTemplate (DefaultSolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder)
		{
			IEnumerable<IWorkspaceFileObject> newItems = null;
			ProjectCreateInformation cinfo = CreateProjectCreateInformation (config, parentFolder);

			if (parentFolder == null) {
				IWorkspaceFileObject newItem = template.Template.CreateWorkspaceItem (cinfo);
				if (newItem != null) {
					newItems = new [] { newItem };
				}
			} else {
				newItems = template.Template.CreateProjects (parentFolder, cinfo);
			}
			return new DefaultProcessedTemplateResult (template.Template, newItems, cinfo.ProjectBasePath);
		}
		public SolutionFolderTestGroup (SolutionFolder c): base (c.Name, c)
		{
			string storeId = c.ItemId;
			string resultsPath = MonoDevelop.NUnit.RootTest.GetTestResultsDirectory (c.BaseDirectory);
			ResultsStore = new BinaryResultsStore (resultsPath, storeId);
			
			folder = c;
			folder.NameChanged += OnCombineRenamed;

			if (c.IsRoot) {
				folder.ParentSolution.SolutionItemAdded += OnEntryChanged;
				folder.ParentSolution.SolutionItemRemoved += OnEntryChanged;
				IdeApp.Workspace.ReferenceAddedToProject += OnReferenceChanged;
				IdeApp.Workspace.ReferenceRemovedFromProject += OnReferenceChanged;
			}
		}
예제 #20
0
		public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
		{
			if (!(entry is DotNetProject) || !GtkDesignInfo.SupportsRefactoring (entry as DotNetProject))
				return FeatureSupportLevel.NotSupported;
			
			ReferenceManager refmgr = new ReferenceManager ((DotNetProject)entry);
			if (refmgr.SupportedGtkVersions.Count == 0)
				return FeatureSupportLevel.NotSupported;
			
			if (GtkDesignInfo.SupportsDesigner ((Project)entry))
				return FeatureSupportLevel.Enabled;
			else if (entry is DotNetAssemblyProject)
				return FeatureSupportLevel.SupportedByDefault;
			else
				return FeatureSupportLevel.Supported;
		}
        public SolutionFolderNode(SolutionFolder solutionFolder, IconProvider iconProvider)
            : base(solutionFolder.FilePath)
        {
            this.SolutionFolder = solutionFolder;
            this._iconProvider = iconProvider;
            Text = solutionFolder.Name;
            UpdateTextOnFilePathChanged = false;

            AddStub();

            ImageIndex = SelectedImageIndex = (_iconProvider = iconProvider).GetImageIndex(solutionFolder);

            solutionFolder.Nodes.InsertedItem += Nodes_InsertedItem;
            solutionFolder.Nodes.RemovedItem += Nodes_RemovedItem;
            solutionFolder.FilePathChanged += solutionFolder_FilePathChanged;
        }
        private static int CountProjects(SolutionFolder folder)
        {
        	int count = 0;
        	
        	if (folder is ProjectEntry || folder is Solution)
        		count++;
        	
        	foreach (var node in folder.Nodes)
        	{
        		if (node is SolutionFolder)
	        	{
        			count += CountProjects(node as SolutionFolder);
	        	}
        	}
        	
        	return count;
        }
        public CreateProjectDialog(SolutionFolder parentFolder)
        {
            _parentFolder = parentFolder;
            _templates = LiteDevelopApplication.Current.ExtensionHost.TemplateService.GetProjectTemplates();

            InitializeComponent();
            templatesListView.TemplateService = LiteDevelopApplication.Current.ExtensionHost.TemplateService;
            SetupMuiComponents();

            checkBox1.Checked = checkBox1.Visible = parentFolder == null;

            if (parentFolder == null)
                directoryTextBox.Text = LiteDevelopSettings.Instance.GetValue("Projects.DefaultProjectsPath");
            else
                directoryTextBox.Text = parentFolder.FilePath.HasExtension ? parentFolder.FilePath.ParentDirectory.FullPath : parentFolder.FilePath.FullPath;

            languagesTreeView.Populate(_templates);
        }
예제 #24
0
 public void addFilesToSolution(Project solutionFolderProject, SolutionFolder solutionFolder, string basePath)
 {
     //For each file, add to the folder
     foreach (var file in Directory.EnumerateFiles(basePath))
     {
         //Add the file as a copy into the solution folder
         solutionFolderProject.ProjectItems.AddFromFileCopy(file);
     }
     //for each directory, create a new solution folder and add the files
     foreach (var dir in Directory.EnumerateDirectories(basePath))
     {
         //Create a new solution folder and return a Project object
         Project folderProject = solutionFolder.AddSolutionFolder(Path.GetFileName(dir));
         //Cast the Project object to a SolutionFolder to be able to create more Solution Folders children
         SolutionFolder solFolder = (SolutionFolder)folderProject.Object;
         //Call the function to add the original files to the solution folder
         addFilesToSolution(folderProject, solFolder, dir);
     }
 }
        private Project AddProject(string projectSufix, string templateName, SolutionFolder sourceSolutionFolder = null, string folderName = null)
        {
            string destination = _replacementsDictionary["$destinationdirectory$"];

            if (_sourceFolder)
            {
                destination = Path.Combine(destination, "Source");
            }

            var projectName = $"{_replacementsDictionary["$safeprojectname$"]}.{projectSufix}";

            Project project;
            if (sourceSolutionFolder == null)
            {
                if (folderName != null)
                {
                    SolutionFolder optionalFolder = _dte.Solution.AddSolutionFolderEx(folderName);
                    project = optionalFolder.AddProject(destination, projectName, templateName);
                }
                else
                {
                    project = _dte.Solution.AddProject(destination, projectName, templateName);
                }
            }
            else
            {
                if (folderName != null)
                {
                    SolutionFolder folder = (SolutionFolder)sourceSolutionFolder.AddSolutionFolderEx(folderName);
                    project = folder.AddProject(destination, projectName, templateName);
                }
                else
                {
                    project = sourceSolutionFolder.AddProject(destination, projectName, templateName);
                }
            }

            return project;
        }
예제 #26
0
		public PackagingFeatureWidget (SolutionFolder parentFolder, SolutionItem entry)
		{
			this.Build();
			this.entry = entry;
			this.parentFolder = parentFolder;
			
			creatingPackProject = entry is PackagingProject;
			
			if (!creatingPackProject) {
				ReadOnlyCollection<PackagingProject> packProjects = parentFolder.ParentSolution.GetAllSolutionItems<PackagingProject> ();
				newPackProject = new PackagingProject ();
			
				string label = GettextCatalog.GetString ("Create packages for this project in a new Packaging Project");
				AddCreatePackageSection (box, label, newPackProject, packProjects.Count > 0);
			
				foreach (PackagingProject project in packProjects)
					AddProject (project);
			} else {
				string label = GettextCatalog.GetString ("Select packages to add to the new Packaging Project");
				AddCreatePackageSection (box, label, (PackagingProject) entry, false);
			}
		}
		public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry)
		{
			TranslationProject newProject;
			if (entry is TranslationProject)
				newProject = (TranslationProject) entry;
			else {
				newProject = new TranslationProject ();
				newProject.Name = entry.Name + "Translation";
				string path = System.IO.Path.Combine (parentCombine.BaseDirectory, newProject.Name);
				if (!System.IO.Directory.Exists (path))
					System.IO.Directory.CreateDirectory (path);
				newProject.FileName = System.IO.Path.Combine (path, newProject.Name + ".mdse");
				parentCombine.Items.Add (newProject);
			}
			
			TreeIter iter;
			if (store.GetIterFirst (out iter)) {
				do {
					string code = (string)store.GetValue (iter, 1);
					newProject.AddNewTranslation (code, new NullProgressMonitor ());
				} while (store.IterNext (ref iter));
			}
		}
예제 #28
0
 public Widget CreateFeatureEditor(SolutionFolder parentCombine, SolutionItem entry)
 {
     return(new GtkFeatureWidget((DotNetProject)entry));
 }
예제 #29
0
        void OpenEvent(object sender, EventArgs e)
        {
            if (!btn_new.Sensitive)
            {
                return;
            }

            if (notebook.Page == 0)
            {
                if (!CreateProject())
                {
                    return;
                }

                Solution parentSolution = null;

                if (parentFolder == null)
                {
                    WorkspaceItem item = (WorkspaceItem)newItem;
                    parentSolution = item as Solution;
                    if (parentSolution != null)
                    {
                        if (parentSolution.RootFolder.Items.Count > 0)
                        {
                            currentEntry = parentSolution.RootFolder.Items [0] as SolutionItem;
                        }
                        parentFolder = parentSolution.RootFolder;
                    }
                }
                else
                {
                    SolutionItem item = (SolutionItem)newItem;
                    parentSolution = parentFolder.ParentSolution;
                    currentEntry   = item;
                }

                if (btn_new.Label == Gtk.Stock.GoForward)
                {
                    // There are features to show. Go to the next page
                    if (currentEntry != null)
                    {
                        try {
                            featureList.Fill(parentFolder, currentEntry, SolutionItemFeatures.GetFeatures(parentFolder, currentEntry));
                        }
                        catch (Exception ex) {
                            LoggingService.LogError(ex.ToString());
                        }
                    }
                    notebook.Page++;
                    btn_new.Label = Gtk.Stock.Ok;
                    return;
                }
            }
            else
            {
                // Already in fetatures page
                if (!featureList.Validate())
                {
                    return;
                }
            }

            // New combines (not added to parent combines) already have the project as child.
            if (!newSolution)
            {
                // Make sure the new item is saved before adding. In this way the
                // version control add-in will be able to put it under version control.
                if (currentEntry is SolutionEntityItem)
                {
                    // Inherit the file format from the solution
                    SolutionEntityItem eitem = (SolutionEntityItem)currentEntry;
                    eitem.FileFormat = parentFolder.ParentSolution.FileFormat;
                    IdeApp.ProjectOperations.Save(eitem);
                }
                parentFolder.AddItem(currentEntry, true);
            }

            if (notebook.Page == 1)
            {
                featureList.ApplyFeatures();
            }

            if (parentFolder != null)
            {
                IdeApp.ProjectOperations.Save(parentFolder.ParentSolution);
            }
            else
            {
                IdeApp.ProjectOperations.Save(newItem);
            }

            if (openSolution)
            {
                var op = selectedItem.OpenCreatedSolution();
                op.Completed += delegate {
                    if (op.Success)
                    {
                        var sol = IdeApp.Workspace.GetAllSolutions().FirstOrDefault();
                        if (sol != null)
                        {
                            InstallProjectTemplatePackages(sol);
                        }
                    }
                };
            }
            else
            {
                // The item is not a solution being opened, so it is going to be added to
                // an existing item. In this case, it must not be disposed by the dialog.
                disposeNewItem = false;
                if (parentFolder != null)
                {
                    InstallProjectTemplatePackages(parentFolder.ParentSolution);
                }
            }

            Respond(ResponseType.Ok);
        }
예제 #30
0
        public SolutionParentViewModel(ISolutionParentViewModel parent, T model) : base(parent, model)
        {
            Items = new ObservableCollection <SolutionItemViewModel>();
            Items.BindCollections(Model.Items, p => { return(SolutionItemViewModel.Create(this, p)); }, (pvm, p) => pvm.Model == p);

            AddNewFolderCommand = ReactiveCommand.Create(() =>
            {
                Model.Solution.AddItem(SolutionFolder.Create("New Folder"), Model);

                Model.Solution.Save();
            });

            AddExistingProjectCommand = ReactiveCommand.Create(async() =>
            {
                var dlg   = new OpenFileDialog();
                dlg.Title = "Open Project";

                var extensions = new List <string>();

                var shell = IoC.Get <IShell>();

                foreach (var projectType in shell.ProjectTypes)
                {
                    extensions.AddRange(projectType.Extensions);
                }

                dlg.Filters.Add(new FileDialogFilter {
                    Name = "AvalonStudio Project", Extensions = extensions
                });

                if (Platform.PlatformIdentifier == Platforms.PlatformID.Win32NT)
                {
                    dlg.InitialDirectory = Model.Solution.CurrentDirectory;
                }
                else
                {
                    dlg.InitialFileName = Model.Solution.CurrentDirectory;
                }

                dlg.AllowMultiple = false;

                var result = await dlg.ShowAsync();

                if (result != null && !string.IsNullOrEmpty(result.FirstOrDefault()))
                {
                    var proj = await Project.LoadProjectFileAsync(Model.Solution, result[0]);

                    if (proj != null)
                    {
                        Model.Solution.AddItem(proj, Model);
                        Model.Solution.Save();
                    }
                }
            });

            AddNewProjectCommand = ReactiveCommand.Create(() =>
            {
                var shell = IoC.Get <IShell>();

                shell.ModalDialog = new NewProjectDialogViewModel(Model);
                shell.ModalDialog.ShowDialog();
            });

            RemoveCommand = ReactiveCommand.Create(() =>
            {
                Model.Solution.RemoveItem(Model);
                Model.Solution.Save();
            });
        }
예제 #31
0
        internal void WriteFileInternal(SlnFile sln, Solution solution, ProgressMonitor monitor)
        {
            SolutionFolder c = solution.RootFolder;

            // Delete data for projects that have been removed from the solution

            var currentProjects = new HashSet <string> (solution.GetAllItems <SolutionFolderItem> ().Select(it => it.ItemId));
            var removedProjects = new HashSet <string> ();

            if (solution.LoadedProjects != null)
            {
                removedProjects.UnionWith(solution.LoadedProjects.Except(currentProjects));
            }
            var unknownProjects = new HashSet <string> (sln.Projects.Select(p => p.Id).Except(removedProjects).Except(currentProjects));

            foreach (var p in removedProjects)
            {
                var ps = sln.Projects.GetProject(p);
                if (ps != null)
                {
                    sln.Projects.Remove(ps);
                }
                var pc = sln.ProjectConfigurationsSection.GetPropertySet(p, true);
                if (pc != null)
                {
                    sln.ProjectConfigurationsSection.Remove(pc);
                }
            }
            var secNested = sln.Sections.GetSection("NestedProjects");

            if (secNested != null)
            {
                foreach (var np in secNested.Properties.ToArray())
                {
                    if (removedProjects.Contains(np.Key) || removedProjects.Contains(np.Value))
                    {
                        secNested.Properties.Remove(np.Key);
                    }
                }
            }
            solution.LoadedProjects = currentProjects;

            //Write the projects
            using (monitor.BeginTask(GettextCatalog.GetString("Saving projects"), 1)) {
                monitor.BeginStep();
                WriteProjects(c, sln, monitor, unknownProjects);
            }

            //FIXME: SolutionConfigurations?

            var pset = sln.SolutionConfigurationsSection;

            foreach (SolutionConfiguration config in solution.Configurations)
            {
                var cid = ToSlnConfigurationId(config);
                pset.SetValue(cid, cid);
            }

            WriteProjectConfigurations(solution, sln);

            //Write Nested Projects
            ICollection <SolutionFolder> folders = solution.RootFolder.GetAllItems <SolutionFolder> ().ToList();

            if (folders.Count > 1)
            {
                // If folders ==1, that's the root folder
                var sec = sln.Sections.GetSection("NestedProjects", SlnSectionType.PreProcess);
                if (sec == null)
                {
                    sec             = sln.Sections.GetOrCreateSection("NestedProjects", SlnSectionType.PreProcess);
                    sec.SkipIfEmpty = true;                     // don't write the section if there are no nested projects after all
                }
                foreach (SolutionFolder folder in folders)
                {
                    if (folder.IsRoot)
                    {
                        continue;
                    }
                    WriteNestedProjects(folder, solution.RootFolder, sec);
                }
                // Remove items which don't have a parent folder
                var toRemove = solution.GetAllItems <SolutionFolderItem> ().Where(it => it.ParentFolder == solution.RootFolder);
                foreach (var it in toRemove)
                {
                    sec.Properties.Remove(it.ItemId);
                }
            }

            // Write custom properties for configurations
            foreach (SolutionConfiguration conf in solution.Configurations)
            {
                string secId = "MonoDevelopProperties." + conf.Id;
                var    sec   = sln.Sections.GetOrCreateSection(secId, SlnSectionType.PreProcess);
                solution.WriteConfigurationData(monitor, sec.Properties, conf);
                if (sec.IsEmpty)
                {
                    sln.Sections.Remove(sec);
                }
            }
        }
예제 #32
0
 public Widget CreateFeatureEditor(SolutionFolder parentCombine, SolutionItem entry)
 {
     return(new GettextFeatureWidget());
 }
예제 #33
0
        public async Task <ProcessedTemplateResult> ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder)
        {
            IProjectTemplatingProvider provider = GetTemplatingProviderForTemplate(template);

            if (provider != null)
            {
                var result = await provider.ProcessTemplate(template, config, parentFolder);

                if (result.WorkspaceItems.Any())
                {
                    RecentTemplates.AddTemplate(template);
                }
                return(result);
            }
            return(null);
        }
예제 #34
0
        public object ReadFile(FilePath fileName, bool hasParentSolution, ProgressMonitor monitor)
        {
            FilePath     basePath = fileName.ParentDirectory;
            MonoMakefile mkfile   = new MonoMakefile(fileName);
            string       aname    = mkfile.GetVariable("LIBRARY");

            if (aname == null)
            {
                aname = mkfile.GetVariable("PROGRAM");
            }

            if (!string.IsNullOrEmpty(aname))
            {
                monitor.BeginTask("Loading '" + fileName + "'", 0);
                var project = Services.ProjectService.CreateProject("C#");
                project.FileName = fileName;

                var ext = new MonoMakefileProjectExtension();
                project.AttachExtension(ext);
                ext.Read(mkfile);

                monitor.EndTask();
                return(project);
            }

            string        subdirs;
            StringBuilder subdirsBuilder = new StringBuilder();

            subdirsBuilder.Append(mkfile.GetVariable("common_dirs"));
            if (subdirsBuilder.Length != 0)
            {
                subdirsBuilder.Append("\t");
                subdirsBuilder.Append(mkfile.GetVariable("net_2_0_dirs"));
            }
            if (subdirsBuilder.Length == 0)
            {
                subdirsBuilder.Append(mkfile.GetVariable("SUBDIRS"));
            }

            subdirs = subdirsBuilder.ToString();
            if (subdirs != null && (subdirs = subdirs.Trim(' ', '\t')) != "")
            {
                object         retObject;
                SolutionFolder folder;
                if (!hasParentSolution)
                {
                    Solution sol = new Solution();
                    sol.AttachExtension(new MonoMakefileSolutionExtension());
                    sol.FileName = fileName;
                    folder       = sol.RootFolder;
                    retObject    = sol;

                    foreach (string conf in MonoMakefile.MonoConfigurations)
                    {
                        SolutionConfiguration sc = new SolutionConfiguration(conf);
                        sol.Configurations.Add(sc);
                    }
                }
                else
                {
                    folder      = new SolutionFolder();
                    folder.Name = Path.GetFileName(Path.GetDirectoryName(fileName));
                    retObject   = folder;
                }

                subdirs = subdirs.Replace('\t', ' ');
                string[] dirs = subdirs.Split(' ');

                monitor.BeginTask("Loading '" + fileName + "'", dirs.Length);
                HashSet <string> added = new HashSet <string> ();
                foreach (string dir in dirs)
                {
                    if (!added.Add(dir))
                    {
                        continue;
                    }
                    monitor.Step(1);
                    if (dir == null)
                    {
                        continue;
                    }
                    string tdir = dir.Trim();
                    if (tdir == "")
                    {
                        continue;
                    }
                    string mfile = Path.Combine(Path.Combine(basePath, tdir), "Makefile");
                    if (File.Exists(mfile) && CanRead(mfile, typeof(SolutionItem)))
                    {
                        SolutionFolderItem it = (SolutionFolderItem)ReadFile(mfile, true, monitor);
                        folder.Items.Add(it);
                    }
                }
                monitor.EndTask();
                return(retObject);
            }
            return(null);
        }
        void CreateStartupModes(Solution sol)
        {
            // Initialize the startup modes
            ReadOnlyCollection <SolutionFolder> folders = sol.GetAllSolutionItems <SolutionFolder> ();

            foreach (SolutionFolder folder in folders)
            {
                CombineStartupMode startupMode = new CombineStartupMode();
                startupMode.SingleStartup  = true;
                startupMode.StartEntryName = null;
                foreach (SolutionItem it in folder.Items)
                {
                    startupMode.AddEntry(it.Name);
                }
                folder.ExtendedProperties ["StartMode"] = startupMode;
            }

            // Get the list of startup items
            IEnumerable <SolutionEntityItem> items;

            if (sol.SingleStartup)
            {
                items = new SolutionEntityItem [] { sol.StartupItem }
            }
            ;
            else
            {
                items = sol.MultiStartupItems;
            }

            // Setup the startup modes
            foreach (SolutionEntityItem it in items)
            {
                if (it == null)
                {
                    continue;
                }
                SolutionFolder folder   = it.ParentFolder;
                SolutionItem   prevItem = it;
                while (folder != null)
                {
                    CombineStartupMode startupMode = (CombineStartupMode)folder.ExtendedProperties ["StartMode"];
                    if (startupMode.SingleStartup)
                    {
                        // If a start entry is already set, convert to multi startup mode
                        if (startupMode.StartEntryName == null)
                        {
                            startupMode.StartEntryName = prevItem.Name;
                        }
                        else if (startupMode.StartEntryName != prevItem.Name)
                        {
                            startupMode.SingleStartup = false;
                            startupMode.MakeExecutable(startupMode.StartEntryName);
                            startupMode.MakeExecutable(prevItem.Name);
                        }
                    }
                    else
                    {
                        // Already multi startup, just add the new item
                        startupMode.MakeExecutable(prevItem.Name);
                    }
                    prevItem = folder;
                    folder   = folder.ParentFolder;
                }
            }

            // Set the startup item for folders which don't have one
            foreach (SolutionFolder folder in folders)
            {
                CombineStartupMode startupMode = (CombineStartupMode)folder.ExtendedProperties ["StartMode"];
                if (startupMode.SingleStartup && startupMode.StartEntryName == null)
                {
                    if (folder.Items.Count > 0)
                    {
                        startupMode.StartEntryName = folder.Items [0].Name;
                    }
                }
            }
        }
예제 #36
0
        public ProcessedTemplateResult ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder)
        {
            IProjectTemplatingProvider provider = GetTemplatingProviderForTemplate(template);

            if (provider != null)
            {
                return(provider.ProcessTemplate(template, config, parentFolder));
            }
            return(null);
        }
예제 #37
0
        public override void Execute()
        {
            DTE dte = GetService <DTE>(true);

            int success     = 0;
            int failures    = 0;
            int overwritten = 0;

            //is item selected, then copy only the item
            if (dte.SelectedItems.Count > 0)
            {
                foreach (SelectedItem item in dte.SelectedItems)
                {
                    if (item is ProjectItem)
                    {
                        DeploymentHelpers.QuickDeployItem(dte, item as ProjectItem, ref success, ref failures, ref overwritten);
                        Helpers.LogMessage(dte, dte, "*** Quick Deploy finished: " + success.ToString() + " successfully (" + overwritten.ToString() + " overwrites), " + failures.ToString() + " failed ***" + Environment.NewLine);
                    }
                    else if (item.ProjectItem is ProjectItem)
                    {
                        DeploymentHelpers.QuickDeployItem(dte, item.ProjectItem as ProjectItem, ref success, ref failures, ref overwritten);
                        Helpers.LogMessage(dte, dte, "*** Quick Deploy finished: " + success.ToString() + " successfully (" + overwritten.ToString() + " overwrites), " + failures.ToString() + " failed ***" + Environment.NewLine);
                    }
                    else if (item.Project != null)
                    {
                        if (item.Project.Object is SolutionFolder)
                        {
                            //solution folder selected
                            SolutionFolder sfolder = item.Project.Object as SolutionFolder;
                            foreach (ProjectItem pitem in sfolder.Parent.ProjectItems)
                            {
                                if (pitem.Object is Project)
                                {
                                    DeploymentHelpers.QuickDeploy(dte, pitem.Object as Project);
                                }
                            }
                        }
                        else
                        {
                            //project selected
                            DeploymentHelpers.QuickDeploy(dte, item.Project);
                        }
                    }
                    else if ((item.Project == null) && (item.ProjectItem == null))
                    {
                        //solution selected
                        List <Project> projects = Helpers.GetSelectedDeploymentProjects(dte);
                        foreach (Project project in projects)
                        {
                            //deployEachProject
                            DeploymentHelpers.QuickDeploy(dte, project);
                        }
                    }
                }
            }
            else
            {
                List <Project> projects = Helpers.GetSelectedDeploymentProjects(dte);
                foreach (Project project in projects)
                {
                    //deployEachProject
                    DeploymentHelpers.QuickDeploy(dte, project);
                }
            }
        }
예제 #38
0
 public AddEntryEventArgs(SolutionFolder combine, string fileName)
 {
     this.combine  = combine;
     this.fileName = fileName;
 }
예제 #39
0
		public SolutionItem AddSolutionItem (SolutionFolder parentFolder)
		{
			SolutionItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = Gtk.FileChooserAction.Open,
				CurrentFolder = parentFolder.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Project Files"), "*.*proj", "*.mdp");
			
			if (dlg.Run ()) {
				try {
					res = AddSolutionItem (parentFolder, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile));
				}
			}
			
			if (res != null)
				IdeApp.Workspace.Save ();

			return res;
		}
예제 #40
0
 public Gtk.Widget CreateFeatureEditor(SolutionFolder parentCombine, SolutionItem entry)
 {
     Gtk.Label label = new Gtk.Label(GettextCatalog.GetString("A new local Git Repository for the solution will be created"));
     label.Show();
     return(label);
 }
예제 #41
0
 public SolutionFolderFileNode(FilePath path, SolutionFolder parent)
 {
     this.Path   = path;
     this.parent = parent;
 }
예제 #42
0
 public static SolutionFolderTestGroup CreateTest(SolutionFolder c)
 {
     return(new SolutionFolderTestGroup(c));
 }
예제 #43
0
        void OpenEvent(object sender, EventArgs e)
        {
            if (!btn_new.Sensitive)
            {
                return;
            }

            if (notebook.Page == 0)
            {
                if (!CreateProject())
                {
                    return;
                }

                Solution parentSolution = null;

                if (parentFolder == null)
                {
                    WorkspaceItem item = (WorkspaceItem)newItem;
                    parentSolution = item as Solution;
                    if (parentSolution != null)
                    {
                        if (parentSolution.RootFolder.Items.Count > 0)
                        {
                            currentEntry = parentSolution.RootFolder.Items [0] as SolutionItem;
                        }
                        parentFolder = parentSolution.RootFolder;
                    }
                }
                else
                {
                    SolutionItem item = (SolutionItem)newItem;
                    parentSolution = parentFolder.ParentSolution;
                    currentEntry   = item;
                }

                if (btn_new.Label == Gtk.Stock.GoForward)
                {
                    // There are features to show. Go to the next page
                    if (currentEntry != null)
                    {
                        try {
                            featureList.Fill(parentFolder, currentEntry, SolutionItemFeatures.GetFeatures(parentFolder, currentEntry));
                        }
                        catch (Exception ex) {
                            LoggingService.LogError(ex.ToString());
                        }
                    }
                    notebook.Page++;
                    btn_new.Label = Gtk.Stock.Ok;
                    return;
                }
            }
            else
            {
                // Already in fetatures page
                if (!featureList.Validate())
                {
                    return;
                }
            }

            // New combines (not added to parent combines) already have the project as child.
            if (!newSolution)
            {
                // Make sure the new item is saved before adding. In this way the
                // version control add-in will be able to put it under version control.
                if (currentEntry is SolutionEntityItem)
                {
                    // Inherit the file format from the solution
                    SolutionEntityItem eitem = (SolutionEntityItem)currentEntry;
                    eitem.FileFormat = parentFolder.ParentSolution.FileFormat;
                    IdeApp.ProjectOperations.Save(eitem);
                }
                parentFolder.AddItem(currentEntry, true);
            }

            if (notebook.Page == 1)
            {
                featureList.ApplyFeatures();
            }

            if (parentFolder != null)
            {
                IdeApp.ProjectOperations.Save(parentFolder.ParentSolution);
            }
            else
            {
                IdeApp.ProjectOperations.Save(newItem);
            }

            if (openSolution)
            {
                selectedItem.OpenCreatedSolution();
            }
            Respond(ResponseType.Ok);
        }
예제 #44
0
 public bool IsEnabled(SolutionFolder parentCombine, SolutionItem entry)
 {
     return(entry is TranslationProject);
 }
예제 #45
0
        public void CtorTest1()
        {
            var f = new SolutionFolder("MyFolder1", ".gnt\\gnt.core", ".gnt\\packages.config");

            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = f.header.pGuid,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core", ".gnt\\packages.config"
                }
            },
                f
            );
            Assert.Equal(2, f.items.Count());
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));
            Assert.Equal((RawText)".gnt\\packages.config", f.items.ElementAt(1));


            f = new SolutionFolder("MyFolder1", ".gnt\\gnt.core");
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = f.header.pGuid,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core"
                }
            },
                f
            );
            Assert.Single(f.items);
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));


            f = new SolutionFolder("MyFolder1");
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = f.header.pGuid,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },
                items = new List <RawText>()
                {
                }
            },
                f
            );
            Assert.Empty(f.items);
        }
예제 #46
0
        public object ReadFile(FilePath fileName, bool hasParentSolution, IProgressMonitor monitor)
        {
            FilePath     basePath = fileName.ParentDirectory;
            MonoMakefile mkfile   = new MonoMakefile(fileName);
            string       aname    = mkfile.GetVariable("LIBRARY");

            if (aname == null)
            {
                aname = mkfile.GetVariable("PROGRAM");
            }

            try {
                ProjectExtensionUtil.BeginLoadOperation();
                if (aname != null)
                {
                    // It is a project
                    monitor.BeginTask("Loading '" + fileName + "'", 0);
                    DotNetAssemblyProject   project = new DotNetAssemblyProject("C#");
                    MonoSolutionItemHandler handler = new MonoSolutionItemHandler(project);
                    ProjectExtensionUtil.InstallHandler(handler, project);
                    project.Name = Path.GetFileName(basePath);
                    handler.Read(mkfile);
                    monitor.EndTask();
                    return(project);
                }
                else
                {
                    string        subdirs;
                    StringBuilder subdirsBuilder = new StringBuilder();
                    subdirsBuilder.Append(mkfile.GetVariable("common_dirs"));
                    if (subdirsBuilder.Length != 0)
                    {
                        subdirsBuilder.Append("\t");
                        subdirsBuilder.Append(mkfile.GetVariable("net_2_0_dirs"));
                    }
                    if (subdirsBuilder.Length == 0)
                    {
                        subdirsBuilder.Append(mkfile.GetVariable("SUBDIRS"));
                    }

                    subdirs = subdirsBuilder.ToString();
                    if (subdirs != null && (subdirs = subdirs.Trim(' ', '\t')) != "")
                    {
                        object         retObject;
                        SolutionFolder folder;
                        if (!hasParentSolution)
                        {
                            Solution sol = new Solution();
                            sol.ConvertToFormat(Services.ProjectService.FileFormats.GetFileFormat("MonoMakefile"), false);
                            sol.FileName = fileName;
                            folder       = sol.RootFolder;
                            retObject    = sol;

                            foreach (string conf in MonoMakefileFormat.Configurations)
                            {
                                SolutionConfiguration sc = new SolutionConfiguration(conf);
                                sol.Configurations.Add(sc);
                            }
                        }
                        else
                        {
                            folder      = new SolutionFolder();
                            folder.Name = Path.GetFileName(Path.GetDirectoryName(fileName));
                            retObject   = folder;
                        }

                        subdirs = subdirs.Replace('\t', ' ');
                        string[] dirs = subdirs.Split(' ');

                        monitor.BeginTask("Loading '" + fileName + "'", dirs.Length);
                        Hashtable added = new Hashtable();
                        foreach (string dir in dirs)
                        {
                            if (added.Contains(dir))
                            {
                                continue;
                            }
                            added.Add(dir, dir);
                            monitor.Step(1);
                            if (dir == null)
                            {
                                continue;
                            }
                            string tdir = dir.Trim();
                            if (tdir == "")
                            {
                                continue;
                            }
                            string mfile = Path.Combine(Path.Combine(basePath, tdir), "Makefile");
                            if (File.Exists(mfile) && CanReadFile(mfile, typeof(SolutionItem)))
                            {
                                SolutionItem it = (SolutionItem)ReadFile(mfile, true, monitor);
                                folder.Items.Add(it);
                            }
                        }
                        monitor.EndTask();
                        return(retObject);
                    }
                }
            } finally {
                ProjectExtensionUtil.EndLoadOperation();
            }
            return(null);
        }
        void AddProject(PackagingProject project)
        {
            string         pname = project.Name;
            SolutionFolder c     = project.ParentFolder;

            while (c != null)
            {
                pname = c.Name + " / " + pname;
                if (c.IsRoot)
                {
                    break;
                }
                c = c.ParentFolder;
            }

            // Get a list of packages that can contain the new project
            ArrayList list = new ArrayList();

            foreach (Package p in project.Packages)
            {
                if (p.PackageBuilder.CanBuild(entry))
                {
                    list.Add(p);
                }
            }

            string label;

            Gtk.VBox vbox;

            if (list.Count > 0)
            {
                label = GettextCatalog.GetString("Add the new project to the Packaging Project '{0}'", pname);
                Gtk.CheckButton checkAddNew = new Gtk.CheckButton(label);
                checkAddNew.Show();
                box.PackStart(checkAddNew, false, false, 0);

                Gtk.Widget hbox;
                AddBox(box, out hbox, out vbox);
                checkAddNew.Toggled += delegate
                {
                    hbox.Visible = checkAddNew.Active;
                    if (!checkAddNew.Active)
                    {
                        DisableChecks(hbox);
                    }
                };

                // Options for adding the project to existing packages

                label = GettextCatalog.GetString("Add the project to existing packages");
                Gtk.CheckButton checkAddExist = new Gtk.CheckButton(label);
                checkAddExist.Show();
                vbox.PackStart(checkAddExist, false, false, 0);

                Gtk.VBox   vboxPacks;
                Gtk.Widget thbox;
                AddBox(vbox, out thbox, out vboxPacks);
                checkAddExist.Toggled += delegate
                {
                    thbox.Visible = checkAddExist.Active;
                    if (!checkAddExist.Active)
                    {
                        DisableChecks(thbox);
                    }
                };

                foreach (Package p in list)
                {
                    label = p.Name;
                    if (label != p.PackageBuilder.Description)
                    {
                        label += " (" + p.PackageBuilder.Description + ")";
                    }
                    Gtk.CheckButton checkPackage = new Gtk.CheckButton(label);
                    checkPackage.Show();
                    vboxPacks.PackStart(checkPackage, false, false, 0);
                    RegisterCheck(checkPackage, project, p);
                }

                // Options for creating new packages

                label = GettextCatalog.GetString("Create new packages for the project");
                AddCreatePackageSection(vbox, label, project, true);
            }
            else
            {
                label = GettextCatalog.GetString("Add new packages for this project in the packaging project '{0}'", pname);
                AddCreatePackageSection(box, label, project, true);
            }
        }
예제 #48
0
        public void CtorTest7()
        {
            var f0 = new SolutionFolder("dir1");

            var f = new SolutionFolder
                    (
                "{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder4", f0,
                (new RawText[] { ".gnt\\gnt.core" }).AsEnumerable()
                    );

            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder4",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    parent   = f0,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core"
                }
            },
                f
            );
            Assert.Single(f.items);
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));


            f = new SolutionFolder
                (
                "{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder1", f0,
                ".gnt\\gnt.core", ".gnt\\packages.config"
                );
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    parent   = f0,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core", ".gnt\\packages.config"
                }
            },
                f
            );
            Assert.Equal(2, f.items.Count());
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));
            Assert.Equal((RawText)".gnt\\packages.config", f.items.ElementAt(1));


            f = new SolutionFolder("{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder2", f0, ".gnt\\gnt.core");
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder2",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    parent   = f0,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core"
                }
            },
                f
            );
            Assert.Single(f.items);
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));


            f = new SolutionFolder("{5D5C7878-22BE-4E5B-BD96-6CBBAC614AD3}", "MyFolder3", f0);
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder3",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{5D5C7878-22BE-4E5B-BD96-6CBBAC614AD3}",
                    parent   = f0,
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },
                items = new List <RawText>()
                {
                }
            },
                f
            );
            Assert.Empty(f.items);
        }
예제 #49
0
파일: Sln.cs 프로젝트: mafaucher/Sharpmake
        private string Generate(
            Solution solution,
            IReadOnlyList <Solution.Configuration> solutionConfigurations,
            string solutionPath,
            string solutionFile,
            bool addMasterBff,
            out bool updated
            )
        {
            // reset current solution state
            _rootSolutionFolders.Clear();
            _solutionFolders.Clear();

            FileInfo solutionFileInfo = new FileInfo(Util.GetCapitalizedPath(solutionPath + Path.DirectorySeparatorChar + solutionFile + SolutionExtension));

            string solutionGuid = Util.BuildGuid(solutionFileInfo.FullName, solution.SharpmakeCsPath);

            DevEnv devEnv = solutionConfigurations[0].Target.GetFragment <DevEnv>();
            List <Solution.ResolvedProject> solutionProjects = ResolveSolutionProjects(solution, solutionConfigurations);

            if (solutionProjects.Count == 0)
            {
                updated = solutionFileInfo.Exists;
                if (updated)
                {
                    Util.TryDeleteFile(solutionFileInfo.FullName);
                }
                return(solutionFileInfo.FullName);
            }

            List <Solution.ResolvedProject> resolvedPathReferences = ResolveReferencesByPath(solutionProjects, solutionConfigurations[0].ProjectReferencesByPath);

            var guidlist = solutionProjects.Select(p => p.UserData["Guid"]);

            resolvedPathReferences = resolvedPathReferences.Where(r => !guidlist.Contains(r.UserData["Guid"])).ToList();

            var fileGenerator = new FileGenerator();

            // write solution header
            switch (devEnv)
            {
            case DevEnv.vs2010: fileGenerator.Write(Template.Solution.HeaderBeginVs2010); break;

            case DevEnv.vs2012: fileGenerator.Write(Template.Solution.HeaderBeginVs2012); break;

            case DevEnv.vs2013: fileGenerator.Write(Template.Solution.HeaderBeginVs2013); break;

            case DevEnv.vs2015: fileGenerator.Write(Template.Solution.HeaderBeginVs2015); break;

            case DevEnv.vs2017: fileGenerator.Write(Template.Solution.HeaderBeginVs2017); break;

            case DevEnv.vs2019: fileGenerator.Write(Template.Solution.HeaderBeginVs2019); break;

            default:
                Console.WriteLine("Unsupported DevEnv for solution " + solutionConfigurations[0].Target.GetFragment <DevEnv>());
                break;
            }

            SolutionFolder masterBffFolder = null;

            if (addMasterBff)
            {
                masterBffFolder = GetSolutionFolder(solution.FastBuildMasterBffSolutionFolder);
                if (masterBffFolder == null)
                {
                    throw new Error("FastBuildMasterBffSolutionFolder needs to be set in solution " + solutionFile);
                }
            }

            // Write all needed folders before the projects to make sure the proper startup project is selected.

            // Ensure folders are always in the same order to avoid random shuffles
            _solutionFolders.Sort((a, b) =>
            {
                int nameComparison = string.Compare(a.Name, b.Name, StringComparison.InvariantCultureIgnoreCase);
                if (nameComparison != 0)
                {
                    return(nameComparison);
                }

                return(a.Guid.CompareTo(b.Guid));
            });

            foreach (SolutionFolder folder in _solutionFolders)
            {
                using (fileGenerator.Declare("folderName", folder.Name))
                    using (fileGenerator.Declare("folderGuid", folder.Guid.ToString().ToUpper()))
                    {
                        fileGenerator.Write(Template.Solution.ProjectFolder);
                        if (masterBffFolder == folder)
                        {
                            var bffFilesPaths = new SortedSet <string>(new FileSystemStringComparer());

                            foreach (var conf in solutionConfigurations)
                            {
                                string masterBffFilePath = conf.MasterBffFilePath + FastBuildSettings.FastBuildConfigFileExtension;
                                bffFilesPaths.Add(Util.PathGetRelative(solutionPath, masterBffFilePath));
                                bffFilesPaths.Add(Util.PathGetRelative(solutionPath, FastBuild.MasterBff.GetGlobalBffConfigFileName(masterBffFilePath)));
                            }

                            // This always needs to be created so make sure it's there.
                            bffFilesPaths.Add(solutionFile + FastBuildSettings.FastBuildConfigFileExtension);

                            fileGenerator.Write(Template.Solution.SolutionItemBegin);
                            {
                                foreach (var path in bffFilesPaths)
                                {
                                    using (fileGenerator.Declare("solutionItemPath", path))
                                        fileGenerator.Write(Template.Solution.SolutionItem);
                                }
                            }
                            fileGenerator.Write(Template.Solution.ProjectSectionEnd);
                        }
                        fileGenerator.Write(Template.Solution.ProjectEnd);
                    }
            }

            Solution.ResolvedProject fastBuildAllProjectForSolutionDependency = null;
            if (solution.FastBuildAllSlnDependencyFromExe)
            {
                var fastBuildAllProjects = solutionProjects.Where(p => p.Project.IsFastBuildAll).ToArray();
                if (fastBuildAllProjects.Length > 1)
                {
                    throw new Error("More than one FastBuildAll project");
                }
                if (fastBuildAllProjects.Length == 1)
                {
                    fastBuildAllProjectForSolutionDependency = fastBuildAllProjects[0];
                }
            }

            using (fileGenerator.Declare("solution", solution))
                using (fileGenerator.Declare("solutionGuid", solutionGuid))
                {
                    foreach (Solution.ResolvedProject resolvedProject in solutionProjects.Concat(resolvedPathReferences).Distinct(new Solution.ResolvedProjectGuidComparer()))
                    {
                        FileInfo projectFileInfo = new FileInfo(resolvedProject.ProjectFile);
                        using (fileGenerator.Declare("project", resolvedProject.Project))
                            using (fileGenerator.Declare("projectName", resolvedProject.ProjectName))
                                using (fileGenerator.Declare("projectFile", Util.PathGetRelative(solutionFileInfo.Directory.FullName, projectFileInfo.FullName)))
                                    using (fileGenerator.Declare("projectGuid", resolvedProject.UserData["Guid"]))
                                        using (fileGenerator.Declare("projectTypeGuid", resolvedProject.UserData["TypeGuid"]))
                                        {
                                            fileGenerator.Write(Template.Solution.ProjectBegin);
                                            Strings buildDepsGuids = new Strings(resolvedProject.Configurations.SelectMany(
                                                                                     c => c.GenericBuildDependencies.Select(
                                                                                         p => p.ProjectGuid ?? ReadGuidFromProjectFile(p.ProjectFullFileNameWithExtension)
                                                                                         )
                                                                                     ));

                                            if (fastBuildAllProjectForSolutionDependency != null)
                                            {
                                                bool writeDependencyToFastBuildAll = (resolvedProject.Configurations.Any(conf => conf.IsFastBuild && conf.Output == Project.Configuration.OutputType.Exe)) ||
                                                                                     solution.ProjectsDependingOnFastBuildAllForThisSolution.Contains(resolvedProject.Project);

                                                if (writeDependencyToFastBuildAll)
                                                {
                                                    buildDepsGuids.Add(fastBuildAllProjectForSolutionDependency.UserData["Guid"] as string);
                                                }
                                            }

                                            if (buildDepsGuids.Any())
                                            {
                                                fileGenerator.Write(Template.Solution.ProjectDependencyBegin);
                                                foreach (string guid in buildDepsGuids)
                                                {
                                                    using (fileGenerator.Declare("projectDependencyGuid", guid))
                                                        fileGenerator.Write(Template.Solution.ProjectDependency);
                                                }
                                                fileGenerator.Write(Template.Solution.ProjectSectionEnd);
                                            }
                                            fileGenerator.Write(Template.Solution.ProjectEnd);
                                        }
                    }
                }

            // Write extra solution items
            // TODO: What happens if we define an existing folder?
            foreach (var items in solution.ExtraItems)
            {
                using (fileGenerator.Declare("folderName", items.Key))
                    using (fileGenerator.Declare("folderGuid", Util.BuildGuid(items.Key)))
                        using (fileGenerator.Declare("solution", solution))
                        {
                            fileGenerator.Write(Template.Solution.ProjectFolder);
                            {
                                fileGenerator.Write(Template.Solution.SolutionItemBegin);
                                foreach (string file in items.Value)
                                {
                                    using (fileGenerator.Declare("solutionItemPath", Util.PathGetRelative(solutionPath, file)))
                                        fileGenerator.Write(Template.Solution.SolutionItem);
                                }
                                fileGenerator.Write(Template.Solution.ProjectSectionEnd);
                            }
                            fileGenerator.Write(Template.Solution.ProjectEnd);
                        }
            }

            fileGenerator.Write(Template.Solution.GlobalBegin);

            // Write source code control information
            if (solution.PerforceRootPath != null)
            {
                List <Solution.ResolvedProject> sccProjects = new List <Solution.ResolvedProject>();

                foreach (Solution.ResolvedProject resolvedProject in solutionProjects)
                {
                    if (resolvedProject.Project.PerforceRootPath != null)
                    {
                        sccProjects.Add(resolvedProject);
                    }
                    else
                    {
                        _builder.LogWriteLine(@"warning: cannot bind solution {0} to perforce, PerforceRootPath for project '{1}' is not set.", solutionFileInfo.Name, resolvedProject.Project.ClassName);
                    }
                }

                if (sccProjects.Count == solutionProjects.Count)
                {
                    using (fileGenerator.Declare("sccNumberOfProjects", sccProjects.Count))
                    {
                        fileGenerator.Write(Template.Solution.GlobalSectionSolutionSourceCodeControlBegin);
                    }

                    for (int i = 0; i < sccProjects.Count; ++i)
                    {
                        Solution.ResolvedProject resolvedProject = sccProjects[i];

                        FileInfo projectFileInfo = new FileInfo(resolvedProject.ProjectFile);

                        //SccProjectUniqueName7 = ..\\..\\extern\\techgroup\\framework\\gear\\private\\compilers\\win32\\vc9\\gear_win32_compile.vcproj
                        string sccProjectUniqueName = Util.PathGetRelative(solutionFileInfo.Directory.FullName, projectFileInfo.FullName).Replace("\\", "\\\\");

                        //SccProjectTopLevelParentUniqueName7 = guildlib.sln
                        string sccProjectTopLevelParentUniqueName = solutionFileInfo.Name;

                        // sln to perforce file
                        //SccLocalPath7 = ..\\..\\extern\\techgroup\\framework\\gear
                        string sccLocalPath = Util.PathGetRelative(solutionPath, resolvedProject.Project.PerforceRootPath).Replace("\\", "\\\\");

                        //SccProjectFilePathRelativizedFromConnection7 = private\\compilers\\win32\\vc9\\
                        string sccProjectFilePathRelativizedFromConnection = Util.PathGetRelative(resolvedProject.Project.PerforceRootPath, projectFileInfo.DirectoryName).Trim('.', '\\').Replace("\\", "\\\\");

                        using (fileGenerator.Declare("i", i))
                            using (fileGenerator.Declare("sccProjectUniqueName", sccProjectUniqueName))
                                using (fileGenerator.Declare("sccProjectTopLevelParentUniqueName", sccProjectTopLevelParentUniqueName))
                                    using (fileGenerator.Declare("sccLocalPath", sccLocalPath))
                                        using (fileGenerator.Declare("sccProjectFilePathRelativizedFromConnection", sccProjectFilePathRelativizedFromConnection))
                                        {
                                            fileGenerator.Write(Template.Solution.GlobalSectionSolutionSourceCodeControlProject);
                                        }
                    }
                    fileGenerator.Write(Template.Solution.GlobalSectionSolutionSourceCodeControlEnd);
                }
            }

            // write solution configurations
            string visualStudioExe = GetVisualStudioIdePath(devEnv) + Util.WindowsSeparator + "devenv.com";

            var configurationSectionNames = new List <string>();

            bool containsMultiDotNetFramework = solutionConfigurations.All(sc => sc.Target.HaveFragment <DotNetFramework>()) &&
                                                solutionConfigurations.Select(sc => sc.Target.GetFragment <DotNetFramework>()).Distinct().Count() > 1;

            var multiDotNetFrameworkConfigurationNames = new HashSet <string>();

            fileGenerator.Write(Template.Solution.GlobalSectionSolutionConfigurationBegin);
            foreach (Solution.Configuration solutionConfiguration in solutionConfigurations)
            {
                string configurationName;
                string category;
                if (solution.MergePlatformConfiguration)
                {
                    configurationName = solutionConfiguration.PlatformName + "-" + solutionConfiguration.Name;
                    category          = "All Platforms";
                }
                else
                {
                    configurationName = solutionConfiguration.Name;
                    category          = solutionConfiguration.PlatformName;
                }

                if (containsMultiDotNetFramework)
                {
                    if (multiDotNetFrameworkConfigurationNames.Contains(configurationName))
                    {
                        continue;
                    }

                    multiDotNetFrameworkConfigurationNames.Add(configurationName);
                }

                using (fileGenerator.Declare("configurationName", configurationName))
                    using (fileGenerator.Declare("category", category))
                    {
                        configurationSectionNames.Add(fileGenerator.Resolver.Resolve(Template.Solution.GlobalSectionSolutionConfiguration));
                    }

                // set the compile command line
                if (File.Exists(visualStudioExe))
                {
                    solutionConfiguration.CompileCommandLine = string.Format(@"""{0}"" ""{1}"" /build ""{2}|{3}""",
                                                                             visualStudioExe, solutionFileInfo.FullName, configurationName, category);
                }
            }

            configurationSectionNames.Sort();

            VerifySectionNamesDuplicates(solutionFileInfo.FullName, solutionConfigurations, configurationSectionNames);

            foreach (string configurationSectionName in configurationSectionNames)
            {
                fileGenerator.Write(configurationSectionName);
            }

            fileGenerator.Write(Template.Solution.GlobalSectionSolutionConfigurationEnd);

            // write all project target and match then to a solution target
            fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationBegin);

            var solutionConfigurationFastBuildBuilt = new Dictionary <Solution.Configuration, List <string> >();

            foreach (Solution.ResolvedProject solutionProject in solutionProjects)
            {
                if (containsMultiDotNetFramework)
                {
                    multiDotNetFrameworkConfigurationNames.Clear();
                }

                foreach (Solution.Configuration solutionConfiguration in solutionConfigurations)
                {
                    ITarget solutionTarget = solutionConfiguration.Target;

                    ITarget projectTarget = null;

                    Solution.Configuration.IncludedProjectInfo includedProject = solutionConfiguration.GetProject(solutionProject.Project.GetType());

                    bool perfectMatch = includedProject != null && solutionProject.Configurations.Contains(includedProject.Configuration);
                    if (perfectMatch)
                    {
                        projectTarget = includedProject.Target;
                    }
                    else
                    {
                        // try to find the target in the project that is the closest match from the solution one
                        int   maxEqualFragments    = 0;
                        int[] solutionTargetValues = solutionTarget.GetFragmentsValue();

                        Platform previousPlatform = Platform._reserved1;

                        foreach (var conf in solutionProject.Configurations)
                        {
                            Platform currentTargetPlatform = conf.Target.GetPlatform();

                            int[] candidateTargetValues = conf.Target.GetFragmentsValue();
                            if (solutionTargetValues.Length != candidateTargetValues.Length)
                            {
                                continue;
                            }

                            int equalFragments = 0;
                            for (int i = 0; i < solutionTargetValues.Length; ++i)
                            {
                                if ((solutionTargetValues[i] & candidateTargetValues[i]) != 0)
                                {
                                    equalFragments++;
                                }
                            }

                            if ((equalFragments == maxEqualFragments && currentTargetPlatform < previousPlatform) || equalFragments > maxEqualFragments)
                            {
                                projectTarget     = conf.Target;
                                maxEqualFragments = equalFragments;
                                previousPlatform  = currentTargetPlatform;
                            }
                        }

                        // last resort: if we didn't find a good enough match, fallback to TargetDefault
                        if (projectTarget == null)
                        {
                            projectTarget = solutionProject.TargetDefault;
                        }
                    }

                    Project.Configuration projectConf = solutionProject.Project.GetConfiguration(projectTarget);

                    if (includedProject != null && includedProject.Configuration.IsFastBuild)
                    {
                        solutionConfigurationFastBuildBuilt.GetValueOrAdd(solutionConfiguration, new List <string>());
                    }

                    Platform projectPlatform = projectTarget.GetPlatform();

                    string configurationName;
                    string category;
                    if (solution.MergePlatformConfiguration)
                    {
                        configurationName = solutionConfiguration.PlatformName + "-" + solutionConfiguration.Name;
                        category          = "All Platforms";
                    }
                    else
                    {
                        configurationName = solutionConfiguration.Name;
                        category          = solutionConfiguration.PlatformName;
                    }

                    if (containsMultiDotNetFramework)
                    {
                        if (multiDotNetFrameworkConfigurationNames.Contains(configurationName))
                        {
                            continue;
                        }

                        multiDotNetFrameworkConfigurationNames.Add(configurationName);
                    }

                    using (fileGenerator.Declare("solutionConf", solutionConfiguration))
                        using (fileGenerator.Declare("projectGuid", solutionProject.UserData["Guid"]))
                            using (fileGenerator.Declare("projectConf", projectConf))
                                using (fileGenerator.Declare("projectPlatform", Util.GetPlatformString(projectPlatform, solutionProject.Project, solutionConfiguration.Target, true)))
                                    using (fileGenerator.Declare("category", category))
                                        using (fileGenerator.Declare("configurationName", configurationName))
                                        {
                                            bool build = false;
                                            if (solution is PythonSolution)
                                            {
                                                // nothing is built in python solutions
                                            }
                                            else if (perfectMatch)
                                            {
                                                build = includedProject.ToBuild == Solution.Configuration.IncludedProjectInfo.Build.Yes;

                                                // for fastbuild, only build the projects that cannot be built through dependency chain
                                                if (!projectConf.IsFastBuild)
                                                {
                                                    build |= includedProject.ToBuild == Solution.Configuration.IncludedProjectInfo.Build.YesThroughDependency;
                                                }
                                                else
                                                {
                                                    if (build)
                                                    {
                                                        solutionConfigurationFastBuildBuilt[solutionConfiguration].Add(projectConf.Project.Name + " " + projectConf.Name);
                                                    }
                                                }
                                            }

                                            fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationActive);
                                            if (build)
                                            {
                                                fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationBuild);

                                                bool deployProject = includedProject.Project.DeployProject || includedProject.Configuration.DeployProject;
                                                if (deployProject)
                                                {
                                                    fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationDeploy);
                                                }
                                            }
                                        }
                }
            }

            foreach (var fb in solutionConfigurationFastBuildBuilt)
            {
                var solutionConfiguration = fb.Key;
                if (fb.Value.Count == 0)
                {
                    Builder.Instance.LogErrorLine($"{solutionFile} - {solutionConfiguration.Name}|{solutionConfiguration.PlatformName} - has no FastBuild projects to build.");
                }
                else if (solution.GenerateFastBuildAllProject && fb.Value.Count > 1)
                {
                    Builder.Instance.LogErrorLine($"{solutionFile} - {solutionConfiguration.Name}|{solutionConfiguration.PlatformName} - has more than one FastBuild project to build ({string.Join(";", fb.Value)}).");
                }
            }

            fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationEnd);

            fileGenerator.Write(Template.Solution.SolutionProperties);

            // Write nested folders

            if (_solutionFolders.Count != 0)
            {
                fileGenerator.Write(Template.Solution.NestedProjectBegin);

                foreach (SolutionFolder folder in _solutionFolders)
                {
                    if (folder.Parent != null)
                    {
                        using (fileGenerator.Declare("nestedChildGuid", folder.Guid.ToString().ToUpper()))
                            using (fileGenerator.Declare("nestedParentGuid", folder.Parent.Guid.ToString().ToUpper()))
                            {
                                fileGenerator.Write(Template.Solution.NestedProjectItem);
                            }
                    }
                }

                foreach (Solution.ResolvedProject resolvedProject in solutionProjects.Concat(resolvedPathReferences))
                {
                    SolutionFolder folder = resolvedProject.UserData["Folder"] as SolutionFolder;

                    if (folder != null)
                    {
                        using (fileGenerator.Declare("nestedChildGuid", resolvedProject.UserData["Guid"].ToString().ToUpper()))
                            using (fileGenerator.Declare("nestedParentGuid", folder.Guid.ToString().ToUpper()))
                            {
                                fileGenerator.Write(Template.Solution.NestedProjectItem);
                            }
                    }
                }

                fileGenerator.Write(Template.Solution.NestedProjectEnd);
            }

            fileGenerator.Write(Template.Solution.GlobalEnd);

            // Write the solution file
            updated = _builder.Context.WriteGeneratedFile(solution.GetType(), solutionFileInfo, fileGenerator.ToMemoryStream());

            solution.PostGenerationCallback?.Invoke(solutionPath, solutionFile, SolutionExtension);

            return(solutionFileInfo.FullName);
        }
예제 #50
0
        public void CtorTest6()
        {
            var f = new SolutionFolder
                    (
                "{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder1",
                new RawText[] { ".gnt\\gnt.core" }
                    );

            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core"
                }
            },
                f
            );
            Assert.Single(f.items);
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));


            f = new SolutionFolder("{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder1", new RawText[] { });
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },
                items = new List <RawText>()
                {
                }
            },
                f
            );
            Assert.Empty(f.items);


            f = new SolutionFolder
                (
                "{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder1",
                (new RawText[] { ".gnt\\gnt.core" }).AsEnumerable()
                );
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core"
                }
            },
                f
            );
            Assert.Single(f.items);
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));
        }
예제 #51
0
 public void ApplyFeature(SolutionFolder parentCombine, SolutionItem entry, Widget editor)
 {
     ((GettextFeatureWidget)editor).ApplyFeature(parentCombine, entry);
 }
예제 #52
0
        public void CtorTest5()
        {
            var f = new SolutionFolder(
                "{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder1",
                new RawText[] { ".gnt\\gnt.core", ".gnt\\packages.config" }
                );

            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    path     = f.header.path,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core", ".gnt\\packages.config"
                }
            },
                f
            );
            Assert.Equal(2, f.items.Count());
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));
            Assert.Equal((RawText)".gnt\\packages.config", f.items.ElementAt(1));


            var f0 = new SolutionFolder();

            f = new SolutionFolder
                (
                "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                "MyFolder1",
                f0,
                ".gnt\\gnt.core", ".gnt\\packages.config"
                );
            Assert.Equal
            (
                new SolutionFolder()
            {
                header = new ProjectItem()
                {
                    name     = "MyFolder1",
                    EpType   = ProjectType.SlnFolder,
                    pType    = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    pGuid    = "{EE7DD6B7-56F4-478D-8745-3D204D915473}",
                    path     = f.header.path,
                    parent   = f0,
                    fullPath = f.header.fullPath,
                },

                items = new List <RawText>()
                {
                    ".gnt\\gnt.core", ".gnt\\packages.config"
                }
            },
                f
            );
            Assert.Equal(2, f.items.Count());
            Assert.Equal((RawText)".gnt\\gnt.core", f.items.ElementAt(0));
            Assert.Equal((RawText)".gnt\\packages.config", f.items.ElementAt(1));
        }
예제 #53
0
        internal void LoadSolution(Solution sol, SlnFile sln, ProgressMonitor monitor, SolutionLoadContext ctx)
        {
            var version = sln.FormatVersion;

            //Parse the .sln file
            var folder = sol.RootFolder;

            sol.Version = "0.1";             //FIXME:

            monitor.BeginTask("Loading projects ..", sln.Projects.Count + 1);
            Dictionary <string, SolutionFolderItem> items = new Dictionary <string, SolutionFolderItem> ();
            List <string> sortedList = new List <string> ();

            List <Task> loadTasks    = new List <Task> ();
            var         solDirectory = Path.GetDirectoryName(sol.FileName);

            foreach (SlnProject sec in sln.Projects)
            {
                // Valid guid?
                if (!Guid.TryParse(sec.TypeGuid, out _))
                {
                    monitor.Step(1);
                    //Use default guid as projectGuid
                    LoggingService.LogDebug(GettextCatalog.GetString(
                                                "Invalid Project type guid '{0}' on line #{1}. Ignoring.",
                                                sec.Id,
                                                sec.Line));
                    continue;
                }

                string projTypeGuid = sec.TypeGuid.ToUpper();
                string projectName  = sec.Name;
                string projectPath  = sec.FilePath;
                string projectGuid  = sec.Id;

                lock (items)
                    sortedList.Add(projectGuid);

                if (projTypeGuid == MSBuildProjectService.FolderTypeGuid)
                {
                    //Solution folder
                    SolutionFolder sfolder = new SolutionFolder();
                    sfolder.Name   = projectName;
                    sfolder.ItemId = projectGuid;

                    DeserializeSolutionItem(monitor, sol, sfolder, sec);

                    foreach (string f in ReadFolderFiles(sec))
                    {
                        sfolder.Files.Add(MSBuildProjectService.FromMSBuildPath(solDirectory, f));
                    }

                    lock (items)
                        items.Add(projectGuid, sfolder);

                    monitor.Step(1);
                    continue;
                }

                if (projectPath.StartsWith("http://", StringComparison.Ordinal))
                {
                    monitor.ReportWarning(GettextCatalog.GetString(
                                              "{0}({1}): Projects with non-local source (http://...) not supported. '{2}'.",
                                              sol.FileName, sec.Line, projectPath));
                    monitor.Step(1);
                    continue;
                }

                string path = MSBuildProjectService.FromMSBuildPath(solDirectory, projectPath);
                if (String.IsNullOrEmpty(path))
                {
                    monitor.ReportWarning(GettextCatalog.GetString(
                                              "Invalid project path found in {0} : {1}", sol.FileName, projectPath));
                    LoggingService.LogWarning(GettextCatalog.GetString(
                                                  "Invalid project path found in {0} : {1}", sol.FileName, projectPath));
                    monitor.Step(1);
                    continue;
                }

                projectPath = Path.GetFullPath(path);

                SolutionItem        item = null;
                Task <SolutionItem> loadTask;
                DateTime            ti = DateTime.Now;

                if (sol.IsSolutionItemEnabled(projectPath))
                {
                    loadTask = Services.ProjectService.ReadSolutionItem(monitor, projectPath, format, projTypeGuid, projectGuid, ctx);
                }
                else
                {
                    loadTask = Task.FromResult <SolutionItem> (new UnloadedSolutionItem()
                    {
                        FileName = projectPath
                    });
                }

                var ft = loadTask.ContinueWith(ta => {
                    try {
                        item = ta.Result;
                        if (item == null)
                        {
                            throw new UnknownSolutionItemTypeException(projTypeGuid);
                        }
                    } catch (Exception cex) {
                        var e = UnwrapException(cex).First();

                        string unsupportedMessage = e.Message;

                        switch (e)
                        {
                        case UserException ex:
                            LoggingService.LogError("{0}: {1}", ex.Message, ex.Details);

                            monitor.ReportError(string.Format("{0}{1}{1}{2}", ex.Message, Environment.NewLine, ex.Details), null);
                            break;

                        case UnknownSolutionItemTypeException ux:
                            LoggingService.LogError("{0}: {1}", ux.Message, projectPath);
                            break;

                        default:
                            LoggingService.LogError(string.Format("Error while trying to load the project {0}", projectPath), e);
                            monitor.ReportWarning(GettextCatalog.GetString(
                                                      "Error while trying to load the project '{0}': {1}", projectPath, e.Message));
                            break;
                        }

                        SolutionItem uitem;
                        uitem = new UnknownSolutionItem()
                        {
                            FileName  = projectPath,
                            LoadError = unsupportedMessage,
                        };
                        item          = uitem;
                        item.ItemId   = projectGuid;
                        item.TypeGuid = projTypeGuid;
                    }

                    item.UnresolvedProjectDependencies = ReadSolutionItemDependencies(sec);

                    // Deserialize the object
                    DeserializeSolutionItem(monitor, sol, item, sec);

                    lock (items) {
                        if (!items.ContainsKey(projectGuid))
                        {
                            items.Add(projectGuid, item);
                        }
                        else
                        {
                            monitor.ReportError(GettextCatalog.GetString("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null);
                        }
                    }
                    monitor.Step(1);
                }, TaskScheduler.Default);
                loadTasks.Add(ft);

                // Limit the number of concurrent tasks. Por solutions with many projects, spawning one thread per
                // project makes the whole load process slower.
                loadTasks.RemoveAll(t => t.IsCompleted);
                if (loadTasks.Count > 4)
                {
                    Task.WaitAny(loadTasks.ToArray());
                }
            }

            Task.WaitAll(loadTasks.ToArray());

            sol.LoadedProjects = new HashSet <string> (items.Keys);

            var nested = sln.Sections.GetSection("NestedProjects");

            if (nested != null)
            {
                LoadNestedProjects(nested, items, monitor);
            }

            // Resolve project dependencies
            foreach (var it in items.Values.OfType <SolutionItem> ())
            {
                if (it.UnresolvedProjectDependencies != null)
                {
                    foreach (var id in it.UnresolvedProjectDependencies.ToArray())
                    {
                        SolutionFolderItem dep;
                        if (items.TryGetValue(id, out dep) && dep is SolutionItem)
                        {
                            it.UnresolvedProjectDependencies.Remove(id);
                            it.ItemDependencies.Add((SolutionItem)dep);
                        }
                    }
                    if (it.UnresolvedProjectDependencies.Count == 0)
                    {
                        it.UnresolvedProjectDependencies = null;
                    }
                }
            }

            //Add top level folders and projects to the main folder
            foreach (string id in sortedList)
            {
                SolutionFolderItem ce;
                if (items.TryGetValue(id, out ce) && ce.ParentFolder == null)
                {
                    folder.Items.Add(ce);
                }
            }

            //FIXME: This can be just SolutionConfiguration also!
            LoadSolutionConfigurations(sln.SolutionConfigurationsSection, sol, monitor);

            LoadProjectConfigurationMappings(sln.ProjectConfigurationsSection, sol, items, monitor);

            foreach (var e in sln.Sections)
            {
                string name = e.Id;
                if (name.StartsWith("MonoDevelopProperties.", StringComparison.Ordinal))
                {
                    int i = name.IndexOf('.');
                    LoadMonoDevelopConfigurationProperties(name.Substring(i + 1), e, sol, monitor);
                }
            }

            monitor.EndTask();
        }
예제 #54
0
        public async Task <ProcessedTemplateResult> ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder)
        {
            var templateInfo   = ((MicrosoftTemplateEngineSolutionTemplate)template).templateInfo;
            var workspaceItems = new List <IWorkspaceFileObject> ();
            var result         = await templateCreator.InstantiateAsync(
                templateInfo,
                config.ProjectName,
                config.GetValidProjectName(),
                config.ProjectLocation,
                new Dictionary <string, string> (),
                true,
                false);

            if (result.ResultInfo.PrimaryOutputs.Any())
            {
                foreach (var res in result.ResultInfo.PrimaryOutputs)
                {
                    var fullPath = Path.Combine(config.ProjectLocation, res.Path);
                    //This happens if some project is excluded by modifiers, e.g. Test project disabled in wizard settings by user
                    if (!File.Exists(fullPath))
                    {
                        continue;
                    }
                    workspaceItems.Add(await MonoDevelop.Projects.Services.ProjectService.ReadSolutionItem(new Core.ProgressMonitor(), fullPath));
                }
            }
            else
            {
                //TODO: Remove this code once https://github.com/dotnet/templating/pull/342 is released in NuGet feed and we bump NuGet version of templating engine
                foreach (var path in Directory.GetFiles(config.ProjectLocation, "*.*proj", SearchOption.AllDirectories))
                {
                    if (path.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase))
                    {
                        workspaceItems.Add(await MonoDevelop.Projects.Services.ProjectService.ReadSolutionItem(new Core.ProgressMonitor(), path));
                    }
                }
            }

            var metadata = new Dictionary <string, string> ();

            metadata ["Id"]       = templateInfo.Identity;
            metadata ["Name"]     = templateInfo.Name;
            metadata ["Language"] = template.Language;
            metadata ["Platform"] = string.Join(";", templateInfo.Classifications);
            TemplateCounter.Inc(1, null, metadata);

            MicrosoftTemplateEngineProcessedTemplateResult processResult;

            if (parentFolder == null)
            {
                var solution = new Solution();
                solution.SetLocation(config.SolutionLocation, config.SolutionName);
                foreach (var item in workspaceItems.Cast <SolutionFolderItem> ())
                {
                    IConfigurationTarget configurationTarget = item as IConfigurationTarget;
                    if (configurationTarget != null)
                    {
                        foreach (ItemConfiguration configuration in configurationTarget.Configurations)
                        {
                            bool flag = false;
                            foreach (SolutionConfiguration solutionCollection in solution.Configurations)
                            {
                                if (solutionCollection.Id == configuration.Id)
                                {
                                    flag = true;
                                }
                            }
                            if (!flag)
                            {
                                solution.AddConfiguration(configuration.Id, true);
                            }
                        }
                    }
                    solution.RootFolder.AddItem(item);
                }
                processResult = new MicrosoftTemplateEngineProcessedTemplateResult(new [] { solution }, solution.FileName, config.ProjectLocation);
            }
            else
            {
                processResult = new MicrosoftTemplateEngineProcessedTemplateResult(workspaceItems.ToArray(), parentFolder.ParentSolution.FileName, config.ProjectLocation);
            }

            // Format all source files generated during the project creation
            foreach (var p in workspaceItems.OfType <Project> ())
            {
                foreach (var file in p.Files)
                {
                    await FormatFile(p, file.FilePath);
                }
            }

            return(processResult);
        }
예제 #55
0
        public override void ActivateMultipleItems()
        {
            SolutionFolder folder = CurrentNode.DataItem as SolutionFolder;

            IdeApp.ProjectOperations.ShowOptions(folder);
        }
예제 #56
0
 public string Validate(SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor)
 {
     return(null);
 }
예제 #57
0
		public SolutionItem CreateProject (SolutionFolder parentFolder)
		{
			string basePath = parentFolder != null ? parentFolder.BaseDirectory : null;
			NewProjectDialog npdlg = new NewProjectDialog (parentFolder, false, basePath);
			if (MessageService.ShowCustomDialog (npdlg) == (int)Gtk.ResponseType.Ok) {
				var item = npdlg.NewItem as SolutionItem;
				if ((item is Project) && ProjectCreated != null)
					ProjectCreated (this, new ProjectCreatedEventArgs (item as Project));
				return item;
			}
			return null;
		}
예제 #58
0
        public override bool HasChildNodes(ITreeBuilder builder, object dataObject)
        {
            SolutionFolder sf = (SolutionFolder)dataObject;

            return(sf.Items.Count > 0 || sf.Files.Count > 0);
        }
예제 #59
0
		public SolutionItem AddSolutionItem (SolutionFolder folder, string entryFileName)
		{
			AddEntryEventArgs args = new AddEntryEventArgs (folder, entryFileName);
			if (AddingEntryToCombine != null)
				AddingEntryToCombine (this, args);
			if (args.Cancel)
				return null;
			using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor (true)) {
				return folder.AddItem (monitor, args.FileName, true);
			}
		}
예제 #60
0
        public override object GetParentObject(object dataObject)
        {
            SolutionFolder sf = (SolutionFolder)dataObject;

            return(sf.IsRoot || sf.ParentFolder.IsRoot ? (object)sf.ParentSolution : (object)sf.ParentFolder);
        }