public bool CanDeploy (SolutionItem entry, MakefileType type)
		{
			Project project = entry as Project;
			if ( project == null ) return false;
			if ( FindSetupForProject ( project ) == null ) return false;
			return true;
		}
		public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
		{
			if (entry is Project)
				return FeatureSupportLevel.SupportedByDefault;
			else
				return FeatureSupportLevel.NotSupported;
		}
        public ProjectFile AddFileToProject(SolutionItem policyParent, Project project, string language, string directory, string name)
        {
            generatedFile = SaveFile (policyParent, project, language, directory, name);
            if (generatedFile != null) {
                string buildAction = this.buildAction ?? project.GetDefaultBuildAction (generatedFile);
                ProjectFile projectFile = project.AddFile (generatedFile, buildAction);

                if (!string.IsNullOrEmpty (dependsOn)) {
                    Dictionary<string,string> tags = new Dictionary<string,string> ();
                    ModifyTags (policyParent, project, language, name, generatedFile, ref tags);
                    string parsedDepName = StringParserService.Parse (dependsOn, tags);
                    if (projectFile.DependsOn != parsedDepName)
                        projectFile.DependsOn = parsedDepName;
                }

                if (!string.IsNullOrEmpty (customTool))
                    projectFile.Generator = customTool;

                DotNetProject netProject = project as DotNetProject;
                if (netProject != null) {
                    // Add required references
                    foreach (string aref in references) {
                        string res = netProject.AssemblyContext.GetAssemblyFullName (aref, netProject.TargetFramework);
                        res = netProject.AssemblyContext.GetAssemblyNameForVersion (res, netProject.TargetFramework);
                        if (!ContainsReference (netProject, res))
                            netProject.References.Add (new ProjectReference (ReferenceType.Package, aref));
                    }
                }

                return projectFile;
            } else
                return null;
        }
		public override bool AddToProject (SolutionItem parent, Project project, string language, string directory, string name)
		{
			// Replace template variables
			
			string cname = Path.GetFileNameWithoutExtension (name);
			string[,] tags = { 
				{"Name", cname},
			};
			
			string content = addinTemplate.OuterXml;
			content = StringParserService.Parse (content, tags);
			
			// Create the manifest
			
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml (content);

			string file = Path.Combine (directory, "manifest.addin.xml");
			doc.Save (file);
			
			project.AddFile (file, BuildAction.EmbeddedResource);
			
			AddinData.EnableAddinAuthoringSupport ((DotNetProject)project);
			return true;
		}
		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);
		}
		public virtual object GetService (SolutionItem item, Type type)
		{
			if (type.IsInstanceOfType (this))
				return this;
			else
				return GetNext (item).GetService (item, type);
		}
		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 (PackageBuilder builder, SolutionItem selection)
		{
			store.Clear ();
			
			this.builder = builder;
			if (selection is SolutionFolder) {
				foreach (SolutionItem e in ((SolutionFolder)selection).GetAllItems ()) {
					if (builder.CanBuild (e))
						selectedEntries [e] = e;
				}
			}
			else if (selection != null) {
				selectedEntries [selection] = selection;
			}
			
			if (selection != null)
				solution = selection.ParentSolution;
			else {
				solution = IdeApp.ProjectOperations.CurrentSelectedSolution;
				if (solution == null) {
					ReadOnlyCollection<Solution> items = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem.GetAllSolutions ();
					if (items.Count > 0)
						solution = items [0];
					else
						return;
				}
			}
			AddEntry (TreeIter.Zero, solution.RootFolder);
		}
Beispiel #9
0
		public DeployDialog (SolutionItem defaultEntry, bool createBuilderOnly)
		{
			this.Build();
			notebook.ShowTabs = false;
			this.defaultEntry = defaultEntry;
			
			if (createBuilderOnly) {
				vboxSaveProject.Hide ();
				checkSave.Active = true;
				checkSave.Hide ();
				saveSeparator.Hide ();
			}
			else {
				pageSave.Hide ();
				FillProjectSelectors ();
			}
			
			store = new ListStore (typeof(Xwt.Drawing.Image), typeof(string), typeof(object));
			targetsTree.Model = store;
			
			targetsTree.HeadersVisible = false;
			CellRendererImage cr = new CellRendererImage();
			cr.Yalign = 0;
			targetsTree.AppendColumn ("", cr, "image", 0);
			targetsTree.AppendColumn ("", new Gtk.CellRendererText(), "markup", 1);
			
			targetsTree.Selection.Changed += delegate (object s, EventArgs a) {
				UpdateButtons ();
			};
			
			FillBuilders ();
			
			UpdateButtons ();
		}
		public override DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration)
		{
			if (entry is IDeployable)
				return new DeployFileCollection (((IDeployable)entry).GetDeployFiles (configuration));
			
			return base.GetDeployFiles (ctx, entry, configuration);
		}
		void AddEntry (TreeIter iter, SolutionItem entry)
		{
			string icon;
			if (entry.ParentFolder == null)
				icon = MonoDevelop.Ide.Gui.Stock.Solution;
			else if (entry is SolutionFolder)
				icon = MonoDevelop.Ide.Gui.Stock.SolutionFolderClosed;
			else if (entry is Project)
				icon = ((Project)entry).StockIcon;
			else
				icon = MonoDevelop.Ide.Gui.Stock.Project;
			
			bool visible = builder.CanBuild (entry);
			bool selected = selectedEntries.ContainsKey (entry);
			
			if (!(entry is SolutionFolder) && !visible)
				return;
			
			if (!iter.Equals (TreeIter.Zero))
				iter = store.AppendValues (iter, icon, entry.Name, entry, selected && visible, visible);
			else
				iter = store.AppendValues (icon, entry.Name, entry, selected && visible, visible);
			
			if (selected)
				tree.ExpandToPath (store.GetPath (iter));
			
			if (entry is SolutionFolder) {
				foreach (SolutionItem ce in ((SolutionFolder)entry).Items) {
					AddEntry (iter, ce);
				}
			}
		}
		public bool BuildEnabledForItem (SolutionItem item)
		{
			foreach (SolutionConfigurationEntry entry in configurations) {
				if (entry.Item == item)
					return entry.Build && item.Configurations [entry.ItemConfiguration] != null;
			}
			return false;
		}
		public static string GetHeader (SolutionItem policyParent, string fileName, bool newFile)
		{
			StandardHeaderPolicy headerPolicy = policyParent != null ? policyParent.Policies.Get<StandardHeaderPolicy> () : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<StandardHeaderPolicy> ();
			TextStylePolicy textPolicy = policyParent != null ? policyParent.Policies.Get<TextStylePolicy> ("text/plain") : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<TextStylePolicy> ("text/plain");
			AuthorInformation authorInfo = policyParent != null ? policyParent.AuthorInformation : AuthorInformation.Default;
			
			return GetHeader (authorInfo, headerPolicy, textPolicy, fileName, newFile);
		}
		public static bool CheckProjectPackageOfExtension (SolutionItem item, string packageExtension)
		{
			var project = item as Project;
			var outputPath = project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
			var outputDirectory = outputPath.ParentDirectory.FullPath.ToString ();
			var files = Directory.GetFiles (outputDirectory);
			return files.Any (f => f.ToLower ().Contains (packageExtension));
		}
		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);
		}
		public string GetMappedConfiguration (SolutionItem item)
		{
			foreach (SolutionConfigurationEntry entry in configurations) {
				if (entry.Item == item)
					return entry.ItemConfiguration;
			}
			return null;
		}
Beispiel #17
0
		protected UnitTest (string name, WorkspaceObject ownerSolutionItem)
		{
			this.name = name;
			this.ownerSolutionItem = ownerSolutionItem;
			ownerSolutionEntityItem = ownerSolutionItem as SolutionItem;
			if (ownerSolutionEntityItem != null)
				ownerSolutionEntityItem.DefaultConfigurationChanged += OnConfugurationChanged;
		}
		public void Install (IProgressMonitor monitor, SolutionItem entry, string appName, string prefix, ConfigurationSelector configuration)
		{
			this.appName = appName;
			
			using (DeployContext ctx = new DeployContext (this, "Linux", prefix)) {
				InstallEntry (monitor, ctx, entry, configuration);
			}
		}
		public SingleItemSolutionRunConfiguration (SolutionItem item, SolutionItemRunConfiguration config): base (item.ItemId + "|" + config?.Name)
		{
			Item = item;
			RunConfiguration = config;
			if (config != null && !config.IsDefaultConfiguration)
				SetName (item.Name + " – " + config.Name);
			else
				SetName (item.Name);
		}
		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;
		}
Beispiel #21
0
		public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
		{
			var path = FilePath.Build (directory, project.Name + "-res.zip");
			var file = new ProjectFile (path, "EmbeddedResource");
			file.ResourceId = "XobotOS.Resources";
			file.Visible = false;
			project.AddFile (file);
			return true;
		}
		public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
		{
			if (!GtkDesignInfo.SupportsDesigner (project)) {
				ReferenceManager mgr = new ReferenceManager (project as DotNetProject);
				mgr.GtkPackageVersion = mgr.DefaultGtkVersion;
				mgr.Dispose ();
			}

			GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) project);
				
			GuiBuilderProject gproject = info.GuiBuilderProject;
			
			string fileName = fileTemplate.GetFileName (policyParent, project, language, directory, name);
			fileTemplate.AddToProject (policyParent, project, language, directory, name);

			ProjectDomService.Parse (project, fileName);
			
			DotNetProject netProject = project as DotNetProject;
			string ns = netProject != null ? netProject.GetDefaultNamespace (fileName) : "";
			string cname = Path.GetFileNameWithoutExtension (fileName);
			string fullName = ns.Length > 0 ? ns + "." + cname : cname;
			string[,] tags = { 
				{"Name", cname},
				{"Namespace", ns},
				{"FullName", fullName}
			};

			XmlElement widgetElem = steticTemplate ["widget"];
			if (widgetElem != null) {
				string content = widgetElem.OuterXml;
				content = StringParserService.Parse (content, tags);
				
				XmlDocument doc = new XmlDocument ();
				doc.LoadXml (content);
				
				gproject.AddNewComponent (doc.DocumentElement);
				gproject.Save (false);
				IdeApp.ProjectOperations.Save (project);
				return true;
			}
			
			widgetElem = steticTemplate ["action-group"];
			if (widgetElem != null) {
				string content = widgetElem.OuterXml;
				content = StringParserService.Parse (content, tags);
				
				XmlDocument doc = new XmlDocument ();
				doc.LoadXml (content);
				
				gproject.SteticProject.AddNewActionGroup (doc.DocumentElement);
				gproject.Save (false);
				IdeApp.ProjectOperations.Save (project);
				return true;
			}
			
			throw new InvalidOperationException ("<widget> or <action-group> element not found in widget template.");
		}
		void AddClasses (ITreeBuilder builder, SolutionItem entry)
		{
			if (entry is SolutionFolder) {
				foreach (SolutionItem e in ((SolutionFolder)entry).Items)
					AddClasses (builder, e);
			} else if (entry is Project) {
				ProjectNodeBuilder.BuildChildNodes (builder, entry as Project);
			}
		}
Beispiel #24
0
			TagModel GetTagModel (SolutionItem policyParent, Project project, string language, string identifier, string fileName)
			{
				var model = new TagModel();
				var projectModel = ProjectTagModel ?? Outer.ProjectTagModel;
				if (projectModel != null)
					model.InnerModels = new [] { projectModel };
				ModifyTags (policyParent, project, language, identifier, fileName, ref model.OverrideTags);
				return model;
			}
		public override void Initialize (OptionsDialog dialog, object dataObject)
		{
			base.Initialize (dialog, dataObject);
			
			solutionItem = dataObject as SolutionItem;
			if (solutionItem != null)
				workspaceItem = solutionItem.ParentSolution;
			else
				workspaceItem = dataObject as WorkspaceItem;
		}
		public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
		{
			ProjectFile file = template.AddFileToProject (policyParent, project, language, directory, name);
			if (file != null) {
				file.BuildAction = BuildAction.EmbeddedResource;
				return true;
			}
			else
				return false;
		}
		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 override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
		{
			ProjectFile file = template.AddFileToProject (policyParent, project, language, directory, name);
			if (file != null) {
				file.BuildAction = BuildAction.Content;
				file.CopyToOutputDirectory = mode;
				return true;
			}
			else
				return false;
		}
		public static bool  IsAddinProject (SolutionItem targettedItem)
		{
			if (targettedItem.ExtendedProperties.Contains (MDToolHelper.PROJECT_GUID_PROP_KEY) == false)
			{
				return false;
			}

			var guids = (string)targettedItem.ExtendedProperties [MDToolHelper.PROJECT_GUID_PROP_KEY];
			return guids.Contains (MDToolHelper.MONO_DEVELOP_ADDIN_PROJECT_GUIDS [0]) 
				&& guids.Contains (MDToolHelper.MONO_DEVELOP_ADDIN_PROJECT_GUIDS [1]);
		}
		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;
		}
        void TrackStartupProject()
        {
            if (currentStartupProject != null && ((currentSolution != null && currentStartupProject != currentSolution.StartupItem) || currentSolution == null))
            {
                currentStartupProject.ExecutionTargetsChanged -= executionTargetsChanged;
                currentStartupProject.Saved -= HandleUpdateCombos;
            }

            if (currentSolution != null)
            {
                currentStartupProject = currentSolution.StartupItem;
                if (currentStartupProject != null)
                {
                    currentStartupProject.ExecutionTargetsChanged += executionTargetsChanged;
                    currentStartupProject.Saved += HandleUpdateCombos;
                }
            }
            else
            {
                currentStartupProject = null;
            }
        }
Beispiel #32
0
        public bool BelongsToItem(IWorkspaceObject item, bool checkHierarchy)
        {
            if (!checkHierarchy)
            {
                return(item == parentObject);
            }

            IWorkspaceObject cit = parentObject;

            do
            {
                if (cit == item)
                {
                    return(true);
                }
                if (cit is SolutionItem)
                {
                    SolutionItem si = (SolutionItem)cit;
                    if (si.ParentFolder != null)
                    {
                        cit = si.ParentFolder;
                    }
                    else
                    {
                        cit = si.ParentSolution;
                    }
                }
                else if (cit is WorkspaceItem)
                {
                    cit = ((WorkspaceItem)cit).ParentWorkspace;
                }
                else
                {
                    cit = null;
                }
            } while (cit != null);

            return(false);
        }
Beispiel #33
0
        public override bool AddToProject(SolutionItem policyParent, Project project,
                                          string language, string directory, string name)
        {
            bool addedSomething = false;

            directory = Path.Combine(directory, dirName);
            if (templates.Count == 0)
            {
                string relPath = FileService.AbsoluteToRelativePath(project.BaseDirectory, directory);
                if (project.AddDirectory(relPath) != null)
                {
                    addedSomething = true;
                }
            }

            foreach (FileDescriptionTemplate t in templates)
            {
                addedSomething |= t.AddToProject(policyParent, project, language, directory, name);
            }

            return(addedSomething);
        }
Beispiel #34
0
        SolutionItem FindEntryMD1(object item, string fileName)
        {
            if (item is SolutionItem)
            {
                string file = MonoDevelop.Projects.Formats.MD1.MD1ProjectService.GetItemFileName((SolutionItem)item);
                if (file != null && FileService.GetFullPath(file) == fileName)
                {
                    return((SolutionItem)item);
                }
            }

            if (item is Solution)
            {
                return(FindEntryMD1(((Solution)item).RootFolder, fileName));
            }
            else if (item is SolutionFolder)
            {
                foreach (SolutionItem ce in ((SolutionFolder)item).Items)
                {
                    SolutionItem fi = FindEntryMD1(ce, fileName);
                    if (fi != null)
                    {
                        return(fi);
                    }
                }
            }
            else if (item is Workspace)
            {
                foreach (WorkspaceItem wi in ((Workspace)item).Items)
                {
                    SolutionItem fi = FindEntryMD1(wi, fileName);
                    if (fi != null)
                    {
                        return(fi);
                    }
                }
            }
            return(null);
        }
        private static string GetResultName(SolutionItem solutionItem, IBuildInfo buildInfo)
        {
            var buildAction             = buildInfo.BuildAction;
            int errorStateProjectsCount = solutionItem.AllProjects.Count(item => item.State.IsErrorState());

            if (buildInfo.BuildIsCancelled)
            {
                return(buildAction.Value == BuildActions.BuildActionClean ? Resources.BuildActionCancelled_Clean : Resources.BuildActionCancelled);
            }
            else if (!buildInfo.BuildedProjects.BuildWithoutErrors)
            {
                return(buildAction.Value == BuildActions.BuildActionClean ? Resources.BuildActionFailed_Clean : Resources.BuildActionFailed);
            }
            else if (errorStateProjectsCount == 0)
            {
                return(buildAction.Value == BuildActions.BuildActionClean ? Resources.BuildActionFinishedSuccessfully_Clean : Resources.BuildActionFinishedSuccessfully);
            }
            else
            {
                return(buildAction.Value == BuildActions.BuildActionClean ? Resources.BuildActionFinished_Clean : Resources.BuildActionFinished);
            }
        }
        protected override void Run()
        {
            SolutionItem entry = IdeApp.ProjectOperations.CurrentSelectedSolutionItem;
            DeployDialog dlg   = new DeployDialog(entry, false);

            try
            {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    if (dlg.SaveToProject)
                    {
                        Package p = new Package();
                        p.Name           = dlg.NewPackageName;
                        p.PackageBuilder = dlg.PackageBuilder;

                        if (dlg.CreateNewProject)
                        {
                            PackagingProject project = new PackagingProject();
                            project.Name     = dlg.NewProjectName;
                            project.FileName = Path.Combine(dlg.NewProjectSolution.BaseDirectory, project.Name + ".mdse");
                            project.Packages.Add(p);
                            dlg.NewProjectSolution.Items.Add(project);
                            IdeApp.ProjectOperations.Save(dlg.NewProjectSolution.ParentSolution);
                        }
                        else
                        {
                            dlg.ExistingPackagingProject.Packages.Add(p);
                            IdeApp.ProjectOperations.Save(dlg.ExistingPackagingProject);
                        }
                    }
                    Package pkg = new Package(dlg.PackageBuilder);
                    DeployOperations.BuildPackage(pkg);
                }
            }
            finally
            {
                dlg.Destroy();
            }
        }
Beispiel #37
0
        public IEnumerable <SolutionItem> CreateProjects(SolutionFolderItem policyParent, ProjectCreateInformation cInfo)
        {
            if (solutionDescriptor.EntryDescriptors.Length == 0)
            {
                throw new InvalidOperationException(GettextCatalog.GetString("Solution template doesn't have any project templates"));
            }

            var solutionEntryItems = new List <SolutionItem> ();

            packageReferencesForCreatedProjects = new List <PackageReferencesForCreatedProject> ();

            foreach (ISolutionItemDescriptor solutionItemDescriptor in GetItemsToCreate(solutionDescriptor, cInfo))
            {
                ProjectCreateInformation itemCreateInfo = GetItemSpecificCreateInfo(solutionItemDescriptor, cInfo);
                itemCreateInfo = new ProjectTemplateCreateInformation(itemCreateInfo, cInfo.ProjectName);

                SolutionItem solutionEntryItem = solutionItemDescriptor.CreateItem(itemCreateInfo, this.languagename);
                if (solutionEntryItem != null)
                {
                    solutionItemDescriptor.InitializeItem(policyParent, itemCreateInfo, this.languagename, solutionEntryItem);

                    SavePackageReferences(solutionEntryItem, solutionItemDescriptor, itemCreateInfo);

                    solutionEntryItems.Add(solutionEntryItem);
                }
            }

            var pDesc    = this.solutionDescriptor.EntryDescriptors.OfType <ProjectDescriptor> ().FirstOrDefault();
            var metadata = new Dictionary <string, string> ();

            metadata ["Id"]       = this.Id;
            metadata ["Name"]     = this.nonLocalizedName;
            metadata ["Language"] = this.LanguageName;
            metadata ["Platform"] = pDesc != null ? pDesc.ProjectType : "Unknown";
            TemplateCounter.Inc(1, null, metadata);

            return(solutionEntryItems);
        }
Beispiel #38
0
        public override bool AddToProject(SolutionItem policyParent, Project project, string language, string directory, string name)
        {
            var file = inner.AddFileToProject(policyParent, project, language, directory, name);

            if (file == null)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(ResourceId))
            {
                file.ResourceId = inner.ProcessContent(ResourceId);
            }

            /* TODO: Add required packages here?
             * var dnproject = project as DotNetProject;
             * if (dnproject != null)
             * {
             * }
             */

            return(true);
        }
        public static async Task <string> GetStartupProjectOutputPathAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsSolutionBuildManager buildManager;
            IVsHierarchy            startupProject;
            Project project;

            try
            {
                buildManager = await VS.Services.GetSolutionBuildManagerAsync();

                ErrorHandler.ThrowOnFailure(buildManager.get_StartupProject(out startupProject));

                project = (Project)await SolutionItem.FromHierarchyAsync(startupProject, (uint)VSConstants.VSITEMID.Root);

                return(await project.GetOutPutAssemblyPathAsync());
            }
            catch
            {
                return(null);
            }
        }
Beispiel #40
0
        public virtual void CopyFrom(PackageBuilder other)
        {
            childEntries = new List <SolutionItemReference> (other.childEntries);
            rootEntry    = other.rootEntry;

            if (other.childCombineEntries != null)
            {
                childCombineEntries = new List <SolutionItem> (other.childCombineEntries);
            }
            else
            {
                childCombineEntries = null;
            }
            if (other.excludedFiles != null)
            {
                excludedFiles = new List <string> (other.excludedFiles);
            }
            else
            {
                excludedFiles = null;
            }
            rootSolutionItem = other.rootSolutionItem;
        }
        public DeployDialog(SolutionItem defaultEntry, bool createBuilderOnly)
        {
            this.Build();
            notebook.ShowTabs = false;
            this.defaultEntry = defaultEntry;

            if (createBuilderOnly)
            {
                vboxSaveProject.Hide();
                checkSave.Active = true;
                checkSave.Hide();
                saveSeparator.Hide();
            }
            else
            {
                pageSave.Hide();
                FillProjectSelectors();
            }

            store             = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(object));
            targetsTree.Model = store;

            targetsTree.HeadersVisible = false;
            Gtk.CellRendererPixbuf cr = new Gtk.CellRendererPixbuf();
            cr.Yalign = 0;
            targetsTree.AppendColumn("", cr, "pixbuf", 0);
            targetsTree.AppendColumn("", new Gtk.CellRendererText(), "markup", 1);

            targetsTree.Selection.Changed += delegate(object s, EventArgs a)
            {
                UpdateButtons();
            };

            FillBuilders();

            UpdateButtons();
        }
        protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            SolutionExplorerWindow solutionExplorer = await VS.Windows.GetSolutionExplorerWindowAsync();

            if (solutionExplorer != null)
            {
                List <SolutionItem> projects = new List <SolutionItem>();
                foreach (SolutionItem item in await solutionExplorer.GetSelectionAsync())
                {
                    SolutionItem project = item.FindParent(SolutionItemType.Project);
                    if (project != null)
                    {
                        projects.Add(project);
                    }
                }

                if (projects.Count > 0)
                {
                    solutionExplorer.SetSelection(projects);
                }
            }
        }
Beispiel #43
0
        string CalcProjectPath(SolutionItem solution, out string projectFilePath, out string serverPath)
        {
            string result = string.Empty;

            serverPath      = string.Empty;
            projectFilePath = string.Empty;
            try {
                result          = GetProjectPath(solution.Path, out serverPath);
                projectFilePath = solution.Path;
            }
            catch {
                foreach (var project in solution.Children)
                {
                    try {
                        result          = GetProjectPath(project.Path, out serverPath);
                        projectFilePath = project.Path;
                        break;
                    }
                    catch {
                    }
                }
            }
            return(result);
        }
Beispiel #44
0
        private static string GetMainString(SolutionItem solutionItem, IBuildInfo buildInfo, BuildMessagesSettings labelsSettings)
        {
            var    unitName      = GetUnitName(solutionItem, buildInfo, labelsSettings);
            var    actionName    = GetActionName(buildInfo.BuildAction.Value);
            var    beginAtString = GetBeginAtString(buildInfo.BuildAction.Value);
            var    timeString    = GetTimeString(buildInfo, labelsSettings);
            string mainString;

            switch (labelsSettings.MajorMessageFormat)
            {
            case BuildMajorMessageFormat.Entire:
                mainString = string.Format(Resources.BuildBeginStateLabelTemplate_Default, actionName, unitName, beginAtString, timeString);
                break;

            case BuildMajorMessageFormat.Unnamed:
                mainString = string.Format(Resources.BuildBeginStateLabelTemplate_ShortForm, actionName, beginAtString, timeString);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(labelsSettings.MajorMessageFormat));
            }

            return(mainString);
        }
        public SolutionItem CreateItem(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            Type type = addin.GetType(typeName, false);

            if (type == null)
            {
                MessageService.ShowError(GettextCatalog.GetString("Can't create project with type : {0}", typeName));
                return(null);
            }

            // TODO NPM: should use the project service
            SolutionItem item = (SolutionItem)Activator.CreateInstance(type);

            item.InitializeFromTemplate(projectCreateInformation, template);

            string newProjectName = StringParserService.Parse(name, new string[, ] {
                { "ProjectName", projectCreateInformation.ProjectName }
            });

            item.Name     = newProjectName;
            item.FileName = Path.Combine(projectCreateInformation.ProjectBasePath, newProjectName);

            return(item);
        }
Beispiel #46
0
        public void ConvertToFormat(object obj)
        {
            if (obj == null)
            {
                return;
            }

            MSBuildHandler handler;
            SolutionItem   item = obj as SolutionItem;

            if (item != null)
            {
                handler = item.GetItemHandler() as MSBuildHandler;
                if (handler != null)
                {
                    handler.SetSolutionFormat(this, true);
                    return;
                }
            }

            MSBuildProjectService.InitializeItemHandler(item);
            handler = (MSBuildHandler)item.ItemHandler;
            handler.SetSolutionFormat(this, true);
        }
Beispiel #47
0
        public async Task <int> Run(string[] arguments)
        {
            DesktopService.Initialize();

            Console.WriteLine(BrandingService.BrandApplicationName("MonoDevelop Gettext Update Tool"));
            foreach (string s in arguments)
            {
                ReadArgument(s);
            }

            if (help)
            {
                Console.WriteLine("gettext-update [options] [project-file]");
                Console.WriteLine("--f --file:FILE   Project or solution file to build.");
                Console.WriteLine("--p --project:PROJECT  Name of the project to build.");
                Console.WriteLine("--sort  Sorts the output po file");
                Console.WriteLine();
                return(0);
            }

            if (file == null)
            {
                var files = Directory.EnumerateFiles(".");
                foreach (string f in files)
                {
                    if (Services.ProjectService.IsWorkspaceItemFile(f))
                    {
                        file = f;
                        break;
                    }
                }
                if (file == null)
                {
                    Console.WriteLine("Solution file not found.");
                    return(1);
                }
            }
            else if (!Services.ProjectService.IsWorkspaceItemFile(file))
            {
                Console.WriteLine("File '{0}' is not a project or solution.", file);
                return(1);
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            monitor.IgnoreLogMessages = true;

            WorkspaceItem centry = await Services.ProjectService.ReadWorkspaceItem(monitor, file);

            monitor.IgnoreLogMessages = false;

            Solution solution = centry as Solution;

            if (solution == null)
            {
                Console.WriteLine("File is not a solution: " + file);
                return(1);
            }

            if (project != null)
            {
                SolutionItem item = solution.FindProjectByName(project);

                if (item == null)
                {
                    Console.WriteLine("The project '" + project + "' could not be found in " + file);
                    return(1);
                }
                TranslationProject tp = item as TranslationProject;
                if (tp == null)
                {
                    Console.WriteLine("The project '" + item.FileName + "' is not a translation project");
                    return(1);
                }
                tp.UpdateTranslations(monitor, sort);
            }
            else
            {
                foreach (TranslationProject p in solution.GetAllItems <TranslationProject>())
                {
                    p.UpdateTranslations(monitor, sort);
                }
            }

            return(0);
        }
Beispiel #48
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> ();

            foreach (SlnProject sec in sln.Projects)
            {
                try {
                    // Valid guid?
                    new Guid(sec.TypeGuid);
                } catch (FormatException) {
                    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(Path.GetDirectoryName(sol.FileName), f));
                    }

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

                    monitor.Step(1);
                    continue;
                }

                if (projectPath.StartsWith("http://"))
                {
                    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(Path.GetDirectoryName(sol.FileName), 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;

                        if (e is UserException)
                        {
                            var ex = (UserException)e;
                            LoggingService.LogError("{0}: {1}", ex.Message, ex.Details);
                            monitor.ReportError(string.Format("{0}{1}{1}{2}", ex.Message, Environment.NewLine, ex.Details), null);
                        }
                        else
                        {
                            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));
                        }

                        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);
                });
                loadTasks.Add(ft);
            }

            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."))
                {
                    int i = name.IndexOf('.');
                    LoadMonoDevelopConfigurationProperties(name.Substring(i + 1), e, sol, monitor);
                }
            }

            monitor.EndTask();
        }
Beispiel #49
0
        // Can add tags for substitution based on project, language or filename.
        // If overriding but still want base implementation's tags, should invoke base method.
        // We supply defaults whenever it is possible, to avoid having unsubstituted tags. However,
        // do not substitute blanks when a sensible default cannot be guessed, because they result
        //in less obvious errors.
        public virtual void ModifyTags(SolutionItem policyParent, Project project, string language,
                                       string identifier, string fileName, ref Dictionary <string, string> tags)
        {
            DotNetProject    netProject        = project as DotNetProject;
            string           languageExtension = "";
            ILanguageBinding binding           = null;

            if (!string.IsNullOrEmpty(language))
            {
                binding = GetLanguageBinding(language);
                if (binding != null)
                {
                    languageExtension = Path.GetExtension(binding.GetFileName("Default")).Remove(0, 1);
                }
            }

            //need a default namespace or if there is no project, substitutions can get very messed up
            string ns;

            if (project is IDotNetFileContainer)
            {
                ns = ((IDotNetFileContainer)project).GetDefaultNamespace(fileName);
            }
            else
            {
                ns = "Application";
            }

            //need an 'identifier' for tag substitution, e.g. class name or page name
            //if not given an identifier, use fileName
            if ((identifier == null) && (fileName != null))
            {
                identifier = Path.GetFileName(fileName);
            }

            if (identifier != null)
            {
                //remove all extensions
                while (Path.GetExtension(identifier).Length > 0)
                {
                    identifier = Path.GetFileNameWithoutExtension(identifier);
                }
                identifier        = CreateIdentifierName(identifier);
                tags ["Name"]     = identifier;
                tags ["FullName"] = ns.Length > 0 ? ns + "." + identifier : identifier;

                //some .NET languages may be able to use keywords as identifiers if they're escaped
                IDotNetLanguageBinding dnb = binding as IDotNetLanguageBinding;
                if (dnb != null)
                {
                    System.CodeDom.Compiler.CodeDomProvider provider = dnb.GetCodeDomProvider();
                    if (provider != null)
                    {
                        tags ["EscapedIdentifier"] = provider.CreateEscapedIdentifier(identifier);
                    }
                }
            }

            tags ["Namespace"] = ns;
            if (policyParent != null)
            {
                tags ["SolutionName"] = policyParent.Name;
            }
            if (project != null)
            {
                tags ["ProjectName"]     = project.Name;
                tags ["SafeProjectName"] = CreateIdentifierName(project.Name);
                var info = project.AuthorInformation ?? AuthorInformation.Default;
                tags ["AuthorCopyright"] = info.Copyright;
                tags ["AuthorCompany"]   = info.Company;
                tags ["AuthorTrademark"] = info.Trademark;
                tags ["AuthorEmail"]     = info.Email;
                tags ["AuthorName"]      = info.Name;
            }
            if ((language != null) && (language.Length > 0))
            {
                tags ["Language"] = language;
            }
            if (languageExtension.Length > 0)
            {
                tags ["LanguageExtension"] = languageExtension;
            }

            if (fileName != FilePath.Null)
            {
                FilePath fileDirectory = Path.GetDirectoryName(fileName);
                if (project != null && project.BaseDirectory != FilePath.Null && fileDirectory.IsChildPathOf(project.BaseDirectory))
                {
                    tags ["ProjectRelativeDirectory"] = fileDirectory.ToRelative(project.BaseDirectory);
                }
                else
                {
                    tags ["ProjectRelativeDirectory"] = fileDirectory;
                }

                tags ["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName);
                tags ["Directory"] = fileDirectory;
                tags ["FileName"]  = fileName;
            }
        }
Beispiel #50
0
 public sealed override bool AddToProject(SolutionItem policyParent, Project project, string language, string directory, string name)
 {
     return(AddFileToProject(policyParent, project, language, directory, name) != null);
 }
 public SolitionEnumeratorHelper(IDteWrapper dte)
 {
     this.dte = dte;
     solution = dte.BuildTree();
 }
Beispiel #52
0
 public override bool CanBuild(SolutionItem entry)
 {
     return(entry is SolutionFolder || entry is SolutionEntityItem);
 }
Beispiel #53
0
        protected override bool OnBuild(IProgressMonitor monitor, DeployContext ctx)
        {
            string       sourceFile;
            SolutionItem entry = RootSolutionItem;

            if (entry is SolutionFolder)
            {
                sourceFile = entry.ParentSolution.FileName;
            }
            else
            {
                sourceFile = ((SolutionEntityItem)entry).FileName;
            }

            AggregatedProgressMonitor mon = new AggregatedProgressMonitor();

            mon.AddSlaveMonitor(monitor, MonitorAction.WriteLog | MonitorAction.ReportError | MonitorAction.ReportWarning | MonitorAction.ReportSuccess);

            string tmpFolder = FileService.CreateTempDirectory();

            try {
                string tf = Path.GetFileNameWithoutExtension(targetFile);
                if (tf.EndsWith(".tar"))
                {
                    tf = Path.GetFileNameWithoutExtension(tf);
                }

                string folder = FileService.GetFullPath(Path.Combine(tmpFolder, tf));
                Directory.CreateDirectory(folder);

                // Export the project

                SolutionItem[] ents   = GetChildEntries();
                string[]       epaths = new string [ents.Length];
                for (int n = 0; n < ents.Length; n++)
                {
                    epaths [n] = ents [n].ItemId;
                }

                Services.ProjectService.Export(mon, sourceFile, epaths, folder, FileFormat);
                if (!mon.AsyncOperation.Success)
                {
                    return(false);
                }

                // Create the archive
                string td = Path.GetDirectoryName(targetFile);
                if (!Directory.Exists(td))
                {
                    Directory.CreateDirectory(td);
                }
                DeployService.CreateArchive(mon, tmpFolder, targetFile);
            }
            finally {
                Directory.Delete(tmpFolder, true);
            }
            if (monitor.AsyncOperation.Success)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Created file: {0}", targetFile));
            }
            return(true);
        }
 // Recurses into children and tests if they are deployable.
 public bool CanDeploy(SolutionItem entry, MakefileType type)
 {
     return(entry is SolutionFolder);
 }
Beispiel #55
0
        // Returns a stream with the content of the file.
        // project and language parameters are optional
        public virtual Stream CreateFileContent(SolutionItem policyParent, Project project, string language, string fileName, string identifier)
        {
            Dictionary <string, string> tags = new Dictionary <string, string> ();

            ModifyTags(policyParent, project, language, identifier, fileName, ref tags);

            string content = CreateContent(project, tags, language);

            content = StringParserService.Parse(content, tags);
            string        mime      = DesktopService.GetMimeTypeForUri(fileName);
            CodeFormatter formatter = !string.IsNullOrEmpty(mime) ? CodeFormatterService.GetFormatter(mime) : null;

            if (formatter != null)
            {
                var formatted = formatter.FormatText(policyParent != null ? policyParent.Policies : null, content);
                if (formatted != null)
                {
                    content = formatted;
                }
            }

            var ms = new MemoryStream();

            var bom = Encoding.UTF8.GetPreamble();

            ms.Write(bom, 0, bom.Length);

            byte[] data;
            if (AddStandardHeader)
            {
                string header = StandardHeaderService.GetHeader(policyParent, fileName, true);
                data = System.Text.Encoding.UTF8.GetBytes(header);
                ms.Write(data, 0, data.Length);
            }

            Mono.TextEditor.TextDocument doc = new Mono.TextEditor.TextDocument();
            doc.Text = content;

            TextStylePolicy textPolicy = policyParent != null?policyParent.Policies.Get <TextStylePolicy> ("text/plain")
                                             : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <TextStylePolicy> ("text/plain");

            string eolMarker = TextStylePolicy.GetEolMarker(textPolicy.EolMarker);

            byte[] eolMarkerBytes = System.Text.Encoding.UTF8.GetBytes(eolMarker);

            var tabToSpaces = textPolicy.TabsToSpaces? new string (' ', textPolicy.TabWidth) : null;

            foreach (Mono.TextEditor.DocumentLine line in doc.Lines)
            {
                var lineText = doc.GetTextAt(line.Offset, line.Length);
                if (tabToSpaces != null)
                {
                    lineText = lineText.Replace("\t", tabToSpaces);
                }
                data = System.Text.Encoding.UTF8.GetBytes(lineText);
                ms.Write(data, 0, data.Length);
                ms.Write(eolMarkerBytes, 0, eolMarkerBytes.Length);
            }

            ms.Position = 0;
            return(ms);
        }
        public Makefile Deploy(AutotoolsContext ctx, SolutionItem entry, IProgressMonitor monitor)
        {
            generateAutotools = ctx.MakefileType == MakefileType.AutotoolsMakefile;

            monitor.BeginTask(GettextCatalog.GetString(
                                  "Creating {0} for Solution {1}",
                                  generateAutotools ? "Makefile.am" : "Makefile", entry.Name), 1);

            Makefile      solutionMakefile = new Makefile();
            StringBuilder solutionTop      = new StringBuilder();

            try
            {
                SolutionFolder solutionFolder  = (SolutionFolder)entry;
                string         targetDirectory = solutionFolder.BaseDirectory;

                StringBuilder subdirs = new StringBuilder();
                subdirs.Append("#Warning: This is an automatically generated file, do not edit!\n");

                if (!generateAutotools)
                {
                    solutionTop.AppendFormat("top_srcdir={0}\n", FileService.AbsoluteToRelativePath(
                                                 entry.BaseDirectory, ctx.TargetSolution.BaseDirectory));
                    solutionTop.Append("include $(top_srcdir)/config.make\n");
                    solutionTop.Append("include $(top_srcdir)/Makefile.include\n");
                    solutionTop.Append("include $(top_srcdir)/rules.make\n\n");
                    solutionTop.Append("#include $(top_srcdir)/custom-hooks.make\n\n");
                }

                ArrayList children = new ArrayList();
                foreach (SolutionConfiguration config in solutionFolder.ParentSolution.Configurations)
                {
                    if (!ctx.IsSupportedConfiguration(config.Id))
                    {
                        continue;
                    }

                    if (generateAutotools)
                    {
                        subdirs.AppendFormat("if {0}\n", "ENABLE_" + ctx.EscapeAndUpperConfigName(config.Id));
                    }
                    else
                    {
                        subdirs.AppendFormat("ifeq ($(CONFIG),{0})\n", ctx.EscapeAndUpperConfigName(config.Id));
                    }

                    subdirs.Append(" SUBDIRS = ");

                    foreach (SolutionItem ce in CalculateSubDirOrder(ctx, solutionFolder, config))
                    {
                        string baseDirectory;
                        if (!(ce is SolutionEntityItem) && !(ce is SolutionFolder))
                        {
                            continue;
                        }

                        // Ignore projects which can't be deployed
                        IMakefileHandler handler = AutotoolsContext.GetMakefileHandler(ce, ctx.MakefileType);
                        if (handler == null)
                        {
                            continue;
                        }

                        baseDirectory = ce.BaseDirectory;

                        if (solutionFolder.BaseDirectory == baseDirectory)
                        {
                            subdirs.Append(" . ");
                        }
                        else
                        {
                            if (!baseDirectory.StartsWith(solutionFolder.BaseDirectory))
                            {
                                throw new Exception(GettextCatalog.GetString(
                                                        "Child projects must be in sub-directories of their parent"));
                            }

                            // add the subdirectory to the list
                            string path = FileService.AbsoluteToRelativePath(targetDirectory, baseDirectory);
                            if (path.StartsWith("." + Path.DirectorySeparatorChar))
                            {
                                path = path.Substring(2);
                            }

                            AutotoolsContext.CheckSpaces(path);
                            subdirs.Append(" ");
                            subdirs.Append(AutotoolsContext.EscapeStringForAutomake(path));
                        }

                        if (!children.Contains(ce))
                        {
                            children.Add(ce);
                        }
                    }
                    subdirs.Append("\nendif\n");
                }
                solutionTop.Append(subdirs.ToString());

                string includedProject = null;

                // deploy recursively
                foreach (SolutionItem ce in children)
                {
                    IMakefileHandler handler = AutotoolsContext.GetMakefileHandler(ce, ctx.MakefileType);
                    Makefile         makefile;
                    string           outpath;
                    if (handler != null && handler.CanDeploy(ce, ctx.MakefileType))
                    {
                        ctx.RegisterBuiltProject(ce);
                        makefile = handler.Deploy(ctx, ce, monitor);

                        if (targetDirectory == ce.BaseDirectory)
                        {
                            if (includedProject != null)
                            {
                                throw new Exception(GettextCatalog.GetString(
                                                        "More than 1 project in the same directory as the top-level solution is not supported."));
                            }

                            // project is in the solution directory
                            string projectMakefileName = ce.Name + ".make";
                            includedProject = String.Format("include {0}", projectMakefileName);
                            outpath         = Path.Combine(targetDirectory, projectMakefileName);
                            ctx.AddGeneratedFile(outpath);

                            if (!generateAutotools)
                            {
                                solutionMakefile.SetVariable("EXTRA_DIST", projectMakefileName);
                            }
                        }
                        else
                        {
                            makefile.AppendToVariable("EXTRA_DIST", generateAutotools ? String.Empty : "Makefile");
                            outpath = Path.Combine(ce.BaseDirectory, "Makefile");
                            if (generateAutotools)
                            {
                                ctx.AddAutoconfFile(outpath);
                                outpath = outpath + ".am";
                            }
                            else
                            {
                                makefile.Append("install: install-local\nuninstall: uninstall-local\nclean: clean-local\n");
                                if (ce is SolutionFolder)
                                {
                                    //non TargetCombine
                                    makefile.Append("dist-local: dist-local-recursive\n");
                                }
                                else
                                {
                                    makefile.Append("include $(top_srcdir)/rules.make\n");
                                }
                            }
                            ctx.AddGeneratedFile(outpath);
                        }

                        StreamWriter writer = new StreamWriter(outpath);
                        makefile.Write(writer);
                        writer.Close();
                    }
                    else
                    {
                        monitor.Log.WriteLine("Project '{0}' skipped.", ce.Name);
                    }
                }

                if (includedProject != null)
                {
                    solutionTop.Append(GettextCatalog.GetString("\n# Include project specific makefile\n"));
                    solutionTop.Append(includedProject);
                }

                if (generateAutotools)
                {
                    solutionMakefile.Append(solutionTop.ToString());
                }
                else
                {
                    TemplateEngine templateEngine = new TemplateEngine();
                    templateEngine.Variables ["MAKEFILE_SOLUTION_TOP"] = solutionTop.ToString();

                    Stream       stream = ctx.GetTemplateStream("Makefile.solution.template");
                    StreamReader reader = new StreamReader(stream);
                    StringWriter sw     = new StringWriter();

                    templateEngine.Process(reader, sw);
                    reader.Close();

                    solutionMakefile.Append(sw.ToString());

                    if (solutionFolder.IsRoot)
                    {
                        // Emit dist and distcheck targets only for TargetCombine
                        reader = new StreamReader(Path.Combine(ctx.TemplateDir, "make-dist.targets"));
                        solutionMakefile.Append(reader.ReadToEnd());
                        reader.Close();
                    }
                }

                monitor.Step(1);
            }
            finally
            {
                monitor.EndTask();
            }
            return(solutionMakefile);
        }
Beispiel #57
0
		protected override void Run ()
		{
			SolutionItem entry = IdeApp.ProjectOperations.CurrentSelectedSolutionItem;
			DeployOperations.Install (entry, IdeApp.Workspace.ActiveConfiguration);
		}
        public void InitializeItem(SolutionFolderItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionItem item)
        {
            MonoDevelop.Projects.Project project = item as MonoDevelop.Projects.Project;

            if (project == null)
            {
                MessageService.ShowError(GettextCatalog.GetString("Can't create project with type: {0}", type));
                return;
            }

            // Set the file before setting the name, to make sure the file extension is kept
            project.FileName = Path.Combine(projectCreateInformation.ProjectBasePath, projectCreateInformation.ProjectName);
            project.Name     = projectCreateInformation.ProjectName;

            var dnp = project as DotNetProject;

            if (dnp != null)
            {
                if (policyParent.ParentSolution != null && !policyParent.ParentSolution.FileFormat.SupportsFramework(dnp.TargetFramework))
                {
                    SetClosestSupportedTargetFramework(policyParent.ParentSolution.FileFormat, dnp);
                }
                var substitution = new string[, ] {
                    { "ProjectName", GetProjectNameForSubstitution(projectCreateInformation) }
                };
                foreach (var desc in references)
                {
                    if (!projectCreateInformation.ShouldCreate(desc.CreateCondition))
                    {
                        continue;
                    }
                    var pr = desc.Create();
                    if (pr.ReferenceType == ReferenceType.Project)
                    {
                        string referencedProjectName = ReplaceParameters(pr.Reference, substitution, projectCreateInformation);
                        var    parsedReference       = ProjectReference.RenameReference(pr, referencedProjectName);
                        dnp.References.Add(parsedReference);
                    }
                    else
                    {
                        dnp.References.Add(pr);
                    }
                }
            }

            foreach (SingleFileDescriptionTemplate resourceTemplate in resources)
            {
                try {
                    if (!projectCreateInformation.ShouldCreate(resourceTemplate.CreateCondition))
                    {
                        continue;
                    }
                    var projectFile = new ProjectFile(resourceTemplate.SaveFile(policyParent, project, defaultLanguage, project.BaseDirectory, null));
                    projectFile.BuildAction = BuildAction.EmbeddedResource;
                    project.Files.Add(projectFile);
                } catch (Exception ex) {
                    if (!IdeApp.IsInitialized)
                    {
                        throw;
                    }
                    MessageService.ShowError(GettextCatalog.GetString("File {0} could not be written.", resourceTemplate.Name), ex);
                }
            }

            foreach (FileDescriptionTemplate fileTemplate in files)
            {
                try {
                    if (!projectCreateInformation.ShouldCreate(fileTemplate.CreateCondition))
                    {
                        continue;
                    }
                    fileTemplate.SetProjectTagModel(projectCreateInformation.Parameters);
                    fileTemplate.AddToProject(policyParent, project, defaultLanguage, project.BaseDirectory, null);
                } catch (Exception ex) {
                    if (!IdeApp.IsInitialized)
                    {
                        throw;
                    }
                    MessageService.ShowError(GettextCatalog.GetString("File {0} could not be written.", fileTemplate.Name), ex);
                } finally {
                    fileTemplate.SetProjectTagModel(null);
                }
            }
        }
Beispiel #59
0
        void LoadProjectConfigurationMappings(SlnPropertySetCollection sets, Solution sln, Dictionary <string, SolutionFolderItem> items, ProgressMonitor monitor)
        {
            if (sets == null)
            {
                return;
            }

            Dictionary <string, SolutionConfigurationEntry> cache = new Dictionary <string, SolutionConfigurationEntry> ();
            Dictionary <string, string> ignoredProjects           = new Dictionary <string, string> ();

            foreach (var pset in sets)
            {
                var projGuid = pset.Id;

                if (!items.ContainsKey(projGuid))
                {
                    if (ignoredProjects.ContainsKey(projGuid))
                    {
                        // already warned
                        continue;
                    }

                    LoggingService.LogWarning(GettextCatalog.GetString("{0} ({1}) : Project with guid = '{2}' not found or not loaded. Ignoring",
                                                                       sln.FileName, pset.Line + 1, projGuid));
                    ignoredProjects [projGuid] = projGuid;
                    continue;
                }

                SolutionFolderItem it;
                if (!items.TryGetValue(projGuid, out it))
                {
                    continue;
                }

                SolutionItem item = it as SolutionItem;

                if (item == null || !item.SupportsConfigurations())
                {
                    continue;
                }

                //Format:
                // {projectGuid}.SolutionConfigName|SolutionPlatform.ActiveCfg = ProjConfigName|ProjPlatform
                // {projectGuid}.SolutionConfigName|SolutionPlatform.Build.0 = ProjConfigName|ProjPlatform
                // {projectGuid}.SolutionConfigName|SolutionPlatform.Deploy.0 = ProjConfigName|ProjPlatform

                foreach (var prop in pset)
                {
                    string action;
                    string projConfig = prop.Value;

                    string left = prop.Key;
                    if (left.EndsWith(".ActiveCfg"))
                    {
                        action = "ActiveCfg";
                        left   = left.Substring(0, left.Length - 10);
                    }
                    else if (left.EndsWith(".Build.0"))
                    {
                        action = "Build.0";
                        left   = left.Substring(0, left.Length - 8);
                    }
                    else if (left.EndsWith(".Deploy.0"))
                    {
                        action = "Deploy.0";
                        left   = left.Substring(0, left.Length - 9);
                    }
                    else
                    {
                        LoggingService.LogWarning(GettextCatalog.GetString("{0} ({1}) : Unknown action. Only ActiveCfg, Build.0 and Deploy.0 supported.",
                                                                           sln.FileName, pset.Line));
                        continue;
                    }

                    string slnConfig = left;

                    string key = projGuid + "." + slnConfig;
                    SolutionConfigurationEntry combineConfigEntry = null;
                    if (cache.ContainsKey(key))
                    {
                        combineConfigEntry = cache [key];
                    }
                    else
                    {
                        combineConfigEntry       = GetConfigEntry(sln, item, slnConfig);
                        combineConfigEntry.Build = false;                         // Not buildable by default. Build will be enabled if a Build.0 entry is found
                        cache [key] = combineConfigEntry;
                    }

                    /* If both ActiveCfg & Build.0 entries are missing
                     * for a project, then default values :
                     *	ActiveCfg : same as the solution config
                     *	Build : true
                     *
                     * ELSE
                     * if Build (true/false) for the project will
                     * will depend on presence/absence of Build.0 entry
                     */

                    if (action == "ActiveCfg")
                    {
                        combineConfigEntry.ItemConfiguration = FromSlnConfigurationId(projConfig);
                    }
                    else if (action == "Build.0")
                    {
                        combineConfigEntry.Build = true;
                    }
                    else if (action == "Deploy.0")
                    {
                        combineConfigEntry.Deploy = true;
                    }
                }
            }
        }
Beispiel #60
0
 public abstract bool AddToProject(SolutionItem policyParent, Project project, string language, string directory, string name);