/// <summary>
		/// Flags Unity projects for debugging with this addin
		/// </summary>
		protected override bool CanExecute (SolutionEntityItem item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (CanExecuteProject (item as Project, context)) {
				return context.ExecutionHandler.CanExecute (new UnityExecutionCommand (item.BaseDirectory.FullPath));
			}
			return base.CanExecute (item, context, configuration);
		}
        public void UpdateImports(SolutionEntityItem item, List<String> imports)
        {
            // Remove imports
            imports.Remove (importCocoaApplication);
            imports.Remove (importConsoleApplication);
            imports.Remove (importCocoaLibrary);

            // Check project nature
            MonobjcProject project = item as MonobjcProject;
            if (project == null) {
                return;
            }

            switch (project.ApplicationType) {
            case MonobjcProjectType.CocoaApplication:
                imports.Add (importCocoaApplication);
                break;
            case MonobjcProjectType.ConsoleApplication:
                imports.Add (importConsoleApplication);
                break;
            case MonobjcProjectType.CocoaLibrary:
                imports.Add (importCocoaLibrary);
                break;
            }
        }
		protected override void Clean (MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
		{
			var proj = item as MonoGameContentProject;
			MonoGameContentProjectConfiguration cfg = null;
			if (proj != null)
				cfg = proj.GetConfiguration (configuration) as MonoGameContentProjectConfiguration;
			if (proj == null) {
				monitor.Log.WriteLine("Cleaning for Unknown MonoGame Project");
				base.Clean (monitor, item, configuration);
			}
			var manager = new PipelineManager(proj.BaseDirectory.FullPath,
			                                  Path.Combine(cfg.OutputDirectory, cfg.MonoGamePlatform),
			                                  cfg.IntermediateOutputDirectory);
			monitor.Log.WriteLine("Detected {0} MonoGame Platform", cfg.MonoGamePlatform);                              
			foreach(var file in proj.Files)
			{
				if (file.BuildAction == "Compile") {
					try {
						monitor.Log.WriteLine("Cleaning {0}", file.FilePath.FileName);
						manager.CleanContent(file.FilePath.FullPath, null);
					}
					catch(Exception ex)
					{
						monitor.Log.WriteLine(ex.Message);
					}
				}
			}
			base.Clean (monitor, item, configuration);
		}
        public static void GenerateExecutionModeCommands(SolutionEntityItem project, CanExecuteDelegate runCheckDelegate, CommandArrayInfo info)
        {
            CommandExecutionContext ctx = new CommandExecutionContext (project, runCheckDelegate);
            bool supportsParameterization = false;

            foreach (List<IExecutionMode> modes in GetExecutionModeCommands (ctx, false, true)) {
                foreach (IExecutionMode mode in modes) {
                    CommandInfo ci = info.Add (mode.Name, new CommandItem (ctx, mode));
                    if ((mode.ExecutionHandler is ParameterizedExecutionHandler) || ((mode is CustomExecutionMode) && ((CustomExecutionMode)mode).PromptForParameters)) {
                        // It will prompt parameters, so we need command to end with '..'.
                        // However, some commands may end with '...' already and we don't want to break
                        // already-translated strings by altering them
                        if (!ci.Text.EndsWith ("..."))
                            ci.Text += "...";
                        supportsParameterization = true;
                    } else {
                        // The parameters window will be shown if ctrl is pressed
                        ci.Description = GettextCatalog.GetString ("Run With: {0}", ci.Text);
                        if (SupportsParameterization (mode, ctx)) {
                            ci.Description += " - " + GettextCatalog.GetString ("Hold Control key to display the execution parameters dialog.");
                            supportsParameterization = true;
                        }
                    }
                }
                if (info.Count > 0)
                    info.AddSeparator ();
            }
            if (supportsParameterization) {
                info.AddSeparator ();
                info.Add (GettextCatalog.GetString ("Edit Custom Modes..."), new CommandItem (ctx, null));
            }
        }
Ejemplo n.º 5
0
		protected override BuildResult Compile (MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
		{
			var proj = item as Project;
			if (proj == null)
				return base.Compile (monitor, item, buildData);
			if (!proj.GetProjectTypes().Any(x => supportedProjectTypes.ContainsKey(x)))
				return base.Compile (monitor, item, buildData);
			var files = buildData.Items.Where(x => x is ProjectFile).Cast<ProjectFile>().ToArray();
			foreach (var file in files.Where(f => f.BuildAction == "MonoGameContentReference")) {
				var path = System.IO.Path.Combine (Path.GetDirectoryName (file.FilePath.ToString ()), "bin", supportedProjectTypes[platform]);
				monitor.Log.WriteLine("Processing {0}", path);	
				if (!Directory.Exists (path))
					continue;
				foreach (var output in Directory.GetFiles (path, "*.*", SearchOption.AllDirectories)) {
					var link = string.Format ("Content{0}",  output.Replace (path, ""));
					if (proj.Files.FirstOrDefault (x => Path.GetFileName (x.FilePath.ToString ()) == Path.GetFileName (output)) == null) {
						monitor.Log.WriteLine ("Auto Including Content {0}", output);
						proj.Files.Add (new ProjectFile (output, BuildAction.BundleResource) {
							Link = new MonoDevelop.Core.FilePath (link),
							Flags = ProjectItemFlags.DontPersist | ProjectItemFlags.Hidden,
							Visible = false,
						});
					}
				}
			}
			return base.Compile (monitor, item, buildData);
		}
        /// <summary>
        ///   Builds the specified solution item.
        /// </summary>
        /// <param name = "monitor">The monitor.</param>
        /// <param name = "item">The item.</param>
        /// <param name = "configuration">The configuration.</param>
        /// <returns>The build result.</returns>
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
        {
            BuildResult result = new BuildResult ();

            // Pre-build
            monitor.BeginTask (GettextCatalog.GetString ("Pre-Building..."), 1);
            this.PreBuild (result, monitor, item, configuration);
            monitor.EndTask();
            if (result.ErrorCount > 0) {
                return result;
            }

            // Build
            monitor.BeginTask (GettextCatalog.GetString ("Building"), 1);
            result.Append (base.Build (monitor, item, configuration));
            monitor.EndTask();
            if (result.ErrorCount > 0) {
                return result;
            }

            // Post-build
            monitor.BeginTask (GettextCatalog.GetString ("Post-Building..."), 1);
            this.PostBuild (result, monitor, item, configuration);
            monitor.EndTask();

            return result;
        }
		public override void SaveProject (IProgressMonitor monitor, SolutionEntityItem item, MSBuildProject project)
		{
			EnsureNuGetPackageBuildImportsTargetUpdater currentUpdater = Updater;
			if (currentUpdater != null) {
				currentUpdater.UpdateProject (project);
			}
		}
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			DotNetProject project = (DotNetProject) entry;
			GtkDesignInfo info = GtkDesignInfo.FromProject (project);

			// The code generator must run in the GUI thread since it needs to
			// access to Gtk classes
			Generator gen = new Generator ();
			lock (gen) {
				Gtk.Application.Invoke (delegate { gen.Run (monitor, project, configuration); });
				Monitor.Wait (gen);
			}
					
			BuildResult res = base.Build (monitor, entry, configuration);

			if (gen.Messages != null) {
				foreach (string s in gen.Messages)
//					res.AddWarning (info.GuiBuilderProject.File, 0, 0, null, s);
// TODO:	Add gtkx file name in the Generator 
					res.AddWarning ("", 0, 0, null, s);
						
				if (gen.Messages.Length > 0)
					info.ForceCodeGenerationOnBuild ();
			}
			return res;
		}
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			BuildResult res = base.Build (monitor, entry, configuration);
			if (res.ErrorCount > 0 || !(entry is DotNetProject))
				return res;
			
			DotNetProject project = (DotNetProject) entry;
			AddinData data = AddinData.GetAddinData (project);
			if (data == null)
				return res;
			
			monitor.Log.WriteLine (AddinManager.CurrentLocalizer.GetString ("Verifying add-in description..."));
			string fileName = data.AddinManifestFileName;
			ProjectFile file = data.Project.Files.GetFile (fileName);
			if (file == null)
				return res;
			
			string addinFile;
			if (file.BuildAction == BuildAction.EmbeddedResource)
				addinFile = project.GetOutputFileName (ConfigurationSelector.Default);
			else
				addinFile = file.FilePath;
			
			AddinDescription desc = data.AddinRegistry.GetAddinDescription (new ProgressStatusMonitor (monitor), addinFile);
			StringCollection errors = desc.Verify ();
			
			foreach (string err in errors) {
				res.AddError (data.AddinManifestFileName, 0, 0, "", err);
				monitor.Log.WriteLine ("ERROR: " + err);
			}
			
			return res;
		}
 protected override BuildResult Compile(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
 {
     #if DEBUG
     monitor.Log.WriteLine("MonoGame Extension Compile Called");
     #endif
     try
     {
         var proj = item as MonoGameProject;
         if (proj == null)
         {
            return base.Compile (monitor, item, buildData);
         }
         monitor.Log.WriteLine("Compiling for {0}", proj.MonoGamePlatform);
         var results = new System.Collections.Generic.List<BuildResult>();
         foreach(var file in proj.Files)
         {
             if (MonoGameBuildAction.IsMonoGameBuildAction(file.BuildAction))
             {
                 buildData.Items.Add(file);
                 var buildResult = MonoGameContentProcessor.Compile(file, monitor, buildData);
                 results.Add(buildResult);
             }
         }
         return base.Compile (monitor, item, buildData).Append(results);
     }
     finally
     {
     #if DEBUG
         monitor.Log.WriteLine("MonoGame Extension Compile Ended");
     #endif
     }
 }
		public override void LoadProject (IProgressMonitor monitor, SolutionEntityItem item, MSBuildProject msproject)
		{
			base.LoadProject (monitor, item, msproject);

			var dnp = item as DotNetProject;
			if (dnp == null)
				return;

			// Convert .projitems imports into project references

			foreach (var sp in msproject.Imports.Where (im => im.Label == "Shared" && im.Project.EndsWith (".projitems"))) {
				var projitemsFile = sp.Project;
				if (!string.IsNullOrEmpty (projitemsFile)) {
					projitemsFile = MSBuildProjectService.FromMSBuildPath (item.ItemDirectory, projitemsFile);
					projitemsFile = Path.Combine (Path.GetDirectoryName (msproject.FileName), projitemsFile);
					if (File.Exists (projitemsFile)) {
						MSBuildSerializer iser = Handler.CreateSerializer ();
						iser.SerializationContext.BaseFile = projitemsFile;
						iser.SerializationContext.ProgressMonitor = monitor;
						MSBuildProject p = new MSBuildProject ();
						p.Load (projitemsFile);
						Handler.LoadProjectItems (p, iser, ProjectItemFlags.Hidden | ProjectItemFlags.DontPersist);
						var r = new ProjectReference (ReferenceType.Project, Path.GetFileNameWithoutExtension (projitemsFile));
						r.Flags = ProjectItemFlags.DontPersist;
						r.SetItemsProjectPath (projitemsFile);
						dnp.References.Add (r);
					}
				}
			}
		}
Ejemplo n.º 12
0
		protected UnitTest (string name, IWorkspaceObject ownerSolutionItem)
		{
			this.name = name;
			this.ownerSolutionItem = ownerSolutionItem;
			ownerSolutionEntityItem = ownerSolutionItem as SolutionEntityItem;
			if (ownerSolutionEntityItem != null)
				ownerSolutionEntityItem.DefaultConfigurationChanged += OnConfugurationChanged;
		}
Ejemplo n.º 13
0
		public bool BuildEnabledForItem (SolutionEntityItem item)
		{
			foreach (SolutionConfigurationEntry entry in configurations) {
				if (entry.Item == item)
					return entry.Build && item.Configurations [entry.ItemConfiguration] != null;
			}
			return false;
		}
Ejemplo n.º 14
0
		protected override void Clean (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			base.Clean (monitor, entry, configuration);
			
			CProject project = (CProject) entry;
			CProjectConfiguration conf = (CProjectConfiguration) project.GetConfiguration (configuration);
			project.Compiler.Clean (project.Files, conf, monitor);
		}
Ejemplo n.º 15
0
		public string GetMappedConfiguration (SolutionEntityItem item)
		{
			foreach (SolutionConfigurationEntry entry in configurations) {
				if (entry.Item == item)
					return entry.ItemConfiguration;
			}
			return null;
		}
 public IEnumerable<string> GetRequiredImports(SolutionEntityItem item)
 {
     MonobjcProject project = item as MonobjcProject;
     if (project != null) {
         if (project.CompileTarget == CompileTarget.Exe)
             yield return target;
     }
 }
		protected override BuildResult Compile (IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
		{
			MoonlightProject proj = item as MoonlightProject;
			if (proj == null)
				return base.Compile (monitor, item, buildData);
			
			var objDir = GetObjDir (proj, buildData.Configuration);
			if (!Directory.Exists (objDir))
				Directory.CreateDirectory (objDir);
			
			var codeDomProvider = proj.LanguageBinding.GetCodeDomProvider ();
			string appName = proj.Name;
			
			var toResGen = new List<FilePath> ();
			List<BuildResult> results = new List<BuildResult> ();
			
			foreach (ProjectFile pf in proj.Files) {
				if (pf.BuildAction == BuildAction.Resource || pf.BuildAction == BuildAction.Page || pf.BuildAction == BuildAction.ApplicationDefinition)
					toResGen.Add (pf.FilePath);
				
				if (pf.FilePath.Extension == ".xaml" && pf.Generator == "MSBuild:MarkupCompilePass1") {
					var outFile = objDir.Combine (proj.LanguageBinding.GetFileName (pf.FilePath.FileName + ".g"));
					buildData.Items.Add (new ProjectFile (outFile, BuildAction.Compile));
					if (!File.Exists (outFile) || File.GetLastWriteTime (outFile) < File.GetLastWriteTime (pf.FilePath)) {
						string rel = pf.ProjectVirtualPath;
						monitor.Log.WriteLine ("Generating codebehind accessors for {0}...", rel);
						BuildResult result = XamlG.GenerateFile (codeDomProvider, appName, pf.FilePath, rel, outFile);
						if (result.Failed)
							return result;
						results.Add (result);
					}
				}
			}
			
			string resFile = objDir.Combine (appName + ".g.resources");
			if (toResGen.Count > 0) {
				DateTime lastMod = DateTime.MinValue;
				if (File.Exists (resFile))
					lastMod = File.GetLastWriteTime (resFile);
				foreach (string f in toResGen) {
					if (File.GetLastWriteTime (f) > lastMod) {
						BuildResult result = Respack (monitor, proj, toResGen, resFile);
						if (result.Failed)
							return result;
						results.Add (result);
						break;
					}
				}
				buildData.Items.Add (new ProjectFile (resFile, BuildAction.EmbeddedResource) {
					ResourceId = appName + ".g.resources"
				});
			} else {
				if (File.Exists (resFile))
					File.Delete (resFile);
			}
			
			return base.Compile (monitor, item, buildData).Append (results);
		}
Ejemplo n.º 18
0
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			CProject project = (CProject) entry;
			CProjectConfiguration conf = (CProjectConfiguration) project.GetConfiguration (configuration);
			if (conf.CompileTarget != CompileTarget.Bin)
				project.WriteMDPkgPackage (configuration);
			
			return base.Build (monitor, entry, configuration);
		}
		void CheckNHibernateProject (SolutionEntityItem item)
		{
			DotNetProject project = item as DotNetProject;
			if (project != null) {
				if (NHibernateService.HasNHibernateProject (project)) {
					NHibernateProject nhproject = NHibernateService.GetNHibernateProject (project);
					nhproject.CheckAndGenerateCodeFiles ();
				}
			}
		}
		protected override void Clean (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			base.Clean (monitor, entry, configuration);
			
			ValaProject project = entry as ValaProject;
			if (project == null)
				return;
			
			project.Compiler.Clean (project.Files, (ValaProjectConfiguration) project.GetConfiguration(configuration), monitor);
		}
Ejemplo n.º 21
0
		public override void Initialize (OptionsDialog dialog, object dataObject)
		{
			base.Initialize (dialog, dataObject);
			
			solutionItem = dataObject as SolutionEntityItem;
			if (solutionItem != null)
				workspaceItem = solutionItem.ParentSolution;
			else
				workspaceItem = dataObject as WorkspaceItem;
		}
		public override void SaveProject (IProgressMonitor monitor, SolutionEntityItem item, MSBuildProject project)
		{
			try {
				MSBuildProjectImportsMerger merger = ImportsMerger;
				if (merger != null) {
					merger.Merge (project);
				}
			} finally {
				ImportsMerger = null;
			}
		}
		public void UpdateImports (SolutionEntityItem item, List<string> imports)
		{
			imports.Remove (target05);
			imports.Remove (target08);
			
			AspNetAppProject project = item as AspNetAppProject;
			if (project != null) {
				if (project.FileFormat.Id == "MSBuild05")
					imports.Add (target05);
				else
					imports.Add (target08);
			}
		}
		ExecutionCommand CreateCommand (SolutionEntityItem item)
		{
			DotNetProject project = item as DotNetProject;
			if (project == null || project.CompileTarget != CompileTarget.Library || project.ParentSolution == null)
				return null;
			
			SolutionAddinData sdata = project.ParentSolution.GetAddinData ();
			if (sdata == null || project.GetAddinData () == null || project.GetAddinData ().IsRoot)
				return null;
				
			RegistryInfo ri = sdata.ExternalRegistryInfo;
			if (ri == null || string.IsNullOrEmpty (ri.TestCommand))
				return null;

			FilePath cmd;
			string args;
			if (ri.TestCommand [0] == '"') {
				// If the file name is quoted, unquote it
				int i = ri.TestCommand.IndexOf ('"', 1);
				if (i == -1)
					throw new UserException ("Invalid add-in test command: " + ri.TestCommand);
				cmd = ri.TestCommand.Substring (1, i - 1);
				args = ri.TestCommand.Substring (i + 1).Trim ();
			} else {
				int i = ri.TestCommand.IndexOf (' ');
				if (i == -1) {
					cmd = ri.TestCommand;
					args = string.Empty;
				} else {
					cmd = ri.TestCommand.Substring (0, i);
					args = ri.TestCommand.Substring (i + 1).Trim ();
				}
			}
			
			// If the command is an absolute file, take it
			// It not, consider it is a file relative to the startup path
			// If a relative file can't be found, use it as is
			
			if (!cmd.IsAbsolute) {
				FilePath absCmd = cmd.ToAbsolute (ri.ApplicationPath);
				if (System.IO.File.Exists (absCmd))
					cmd = absCmd;
			}
			
			ProcessExecutionCommand pcmd = Runtime.ProcessService.CreateCommand (cmd) as ProcessExecutionCommand;
			if (pcmd == null)
				return null;
			pcmd.Arguments = args;
			pcmd.EnvironmentVariables ["MONO_ADDINS_REGISTRY"] = sdata.TestRegistryPath;
			return pcmd;
		}
		protected override void Clean (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			SolutionItemConfiguration conf = entry.GetConfiguration (configuration) as SolutionItemConfiguration;
			if (conf != null) {
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.BeforeClean, configuration);
				if (monitor.IsCancelRequested)
					return;
			}
			
			base.Clean (monitor, entry, configuration);
			
			if (conf != null && !monitor.IsCancelRequested)
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.AfterClean, configuration);
		}
		public override void Save (IProgressMonitor monitor, SolutionEntityItem entry)
		{
			base.Save (monitor, entry);
			
			DotNetProject project = entry as DotNetProject;
			if (project != null) {
				AddinData data = AddinData.GetAddinData (project);
				if (data != null) {
					Gtk.Application.Invoke (delegate {
						data.CheckOutputPath ();
					});
				}
			}
		}
Ejemplo n.º 27
0
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			DotNetProject project = entry as DotNetProject;
			AddinData data = project != null ? AddinData.GetAddinData (project) : null;
			if (data != null)
				monitor.BeginTask (null, buildingSolution ? 2 : 3);
			
			BuildResult res = base.Build (monitor, entry, configuration);
			if (res.ErrorCount > 0 || data == null)
				return res;
			
			monitor.Step (1);
			
			monitor.Log.WriteLine (AddinManager.CurrentLocalizer.GetString ("Verifying add-in description..."));
			string fileName = data.AddinManifestFileName;
			ProjectFile file = data.Project.Files.GetFile (fileName);
			if (file == null)
				return res;
			
			string addinFile;
			if (file.BuildAction == BuildAction.EmbeddedResource)
				addinFile = project.GetOutputFileName (ConfigurationSelector.Default);
			else
				addinFile = file.FilePath;
			
			AddinDescription desc = data.AddinRegistry.GetAddinDescription (new ProgressStatusMonitor (monitor), addinFile);
			StringCollection errors = desc.Verify ();
			
			foreach (string err in errors) {
				res.AddError (data.AddinManifestFileName, 0, 0, "", err);
				monitor.Log.WriteLine ("ERROR: " + err);
			}
			
			if (!buildingSolution && project.ParentSolution != null) {
				monitor.Step (1);
				SolutionAddinData sdata = project.ParentSolution.GetAddinData ();
				if (sdata != null && sdata.Registry != null) {
					sdata.Registry.Update (new ProgressStatusMonitor (monitor));
					DispatchService.GuiDispatch (delegate {
						sdata.NotifyChanged ();
					});
				}
			}
			
			monitor.EndTask ();
			
			return res;
		}
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			SolutionItemConfiguration conf = entry.GetConfiguration (configuration) as SolutionItemConfiguration;
			if (conf != null) {
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.BeforeBuild, configuration);
				if (monitor.IsCancelRequested)
					return new BuildResult (new CompilerResults (null), "");
			}
			
			BuildResult res = base.Build (monitor, entry, configuration);
			
			if (conf != null && !monitor.IsCancelRequested && !res.Failed)
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.AfterBuild, configuration);
				                                    
			return res;
		}
 protected override BuildResult Build(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
 {
     #if DEBUG
     monitor.Log.WriteLine("MonoGame Extension Build Called");
     #endif
     try
     {
       return base.Build (monitor, item, configuration);
     }
     finally
     {
     #if DEBUG
        monitor.Log.WriteLine("MonoGame Extension Build Ended");
     #endif
     }
 }
		protected override void Execute (IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
		{
			SolutionItemConfiguration conf = entry.GetConfiguration (configuration) as SolutionItemConfiguration;
			if (conf != null) {
				ExecutionContext localContext = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory);
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.BeforeExecute, localContext, configuration);
				if (monitor.IsCancelRequested)
					return;
			}
			
			base.Execute (monitor, entry, context, configuration);
			
			if (conf != null && !monitor.IsCancelRequested) {
				ExecutionContext localContext = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory);
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.AfterExecute, localContext, configuration);
			}
		}
Ejemplo n.º 31
0
 public ProjectOptionsDialog(Gtk.Window parentWindow, SolutionEntityItem project) : base(parentWindow, project)
 {
     this.Title         = GettextCatalog.GetString("Project Options") + " - " + project.Name;
     this.DefaultWidth  = 960;
     this.DefaultHeight = 680;
 }
Ejemplo n.º 32
0
 public virtual bool CanHandleItem(SolutionEntityItem item)
 {
     return(!(IsMigration && IsMigrationRequired) && Type.IsAssignableFrom(item.GetType()));
 }
Ejemplo n.º 33
0
 public virtual bool CanHandleItem(SolutionEntityItem item)
 {
     return(Type.IsAssignableFrom(item.GetType()));
 }
Ejemplo n.º 34
0
        public static void GenerateExecutionModeCommands(SolutionEntityItem project, CanExecuteDelegate runCheckDelegate, CommandArrayInfo info)
        {
            CommandExecutionContext ctx   = new CommandExecutionContext(project, runCheckDelegate);
            bool supportsParameterization = false;

            foreach (List <IExecutionMode> modes in GetExecutionModeCommands(ctx, false, true))
            {
                foreach (IExecutionMode mode in modes)
                {
                    CommandInfo ci = info.Add(mode.Name, new CommandItem(ctx, mode));
                    if ((mode.ExecutionHandler is ParameterizedExecutionHandler) || ((mode is CustomExecutionMode) && ((CustomExecutionMode)mode).PromptForParameters))
                    {
                        // It will prompt parameters, so we need command to end with '..'.
                        // However, some commands may end with '...' already and we don't want to break
                        // already-translated strings by altering them
                        if (!ci.Text.EndsWith("..."))
                        {
                            ci.Text += "...";
                        }
                        supportsParameterization = true;
                    }
                    else
                    {
                        // The parameters window will be shown if ctrl is pressed
                        ci.Description = GettextCatalog.GetString("Run With: {0}", ci.Text);
                        if (SupportsParameterization(mode, ctx))
                        {
                            ci.Description          += " - " + GettextCatalog.GetString("Hold Control key to display the execution parameters dialog.");
                            supportsParameterization = true;
                        }
                    }
                }
                if (info.Count > 0)
                {
                    info.AddSeparator();
                }
            }

            var targets = new List <ExecutionTarget> ();

            if (project != null)
            {
                FlattenExecutionTargets(targets, project.GetExecutionTargets(IdeApp.Workspace.ActiveConfiguration));
            }

            if (targets.Count > 1)
            {
                foreach (var t in targets)
                {
                    var         h  = new TargetedExecutionHandler(Runtime.ProcessService.DefaultExecutionHandler, t);
                    CommandInfo ci = info.Add(t.FullName, new CommandItem(ctx, new ExecutionMode(t.Id, t.FullName, h)));
                    ci.Description = GettextCatalog.GetString("Run With: {0}", ci.Text);
                }
                info.AddSeparator();
            }

            if (supportsParameterization)
            {
                info.AddSeparator();
                info.Add(GettextCatalog.GetString("Edit Custom Modes..."), new CommandItem(ctx, null));
            }
        }
Ejemplo n.º 35
0
 public override bool CanHandleItem(SolutionEntityItem item)
 {
     return(true);
 }
Ejemplo n.º 36
0
        public StartupOptionsPanelWidget(Solution sol)
        {
            this.Build();
            this.sol = sol;

            startupItems = new List <SolutionEntityItem> ();
            foreach (SolutionEntityItem it in sol.GetAllSolutionItems <SolutionEntityItem> ())
            {
                // Include in the list if it can run in any of the existing execution modes and configurations
                foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes())
                {
                    bool matched = false;
                    foreach (IExecutionMode mode in mset.ExecutionModes)
                    {
                        foreach (SolutionConfiguration sc in sol.Configurations)
                        {
                            if (it.CanExecute(new ExecutionContext(mode, null, IdeApp.Workspace.ActiveExecutionTarget), sc.Selector))
                            {
                                startupItems.Add(it);
                                matched = true;
                                break;
                            }
                        }
                        if (matched)
                        {
                            break;
                        }
                    }
                    if (matched)
                    {
                        break;
                    }
                }
            }

            listStore       = new ListStore(typeof(SolutionItem), typeof(bool), typeof(string));
            treeItems.Model = listStore;

            CellRendererToggle crt = new CellRendererToggle();

            treeItems.AppendColumn("", crt, "active", 1);
            treeItems.AppendColumn(GettextCatalog.GetString("Project"), new CellRendererText(), "text", 2);

            if (startupItems.Count > 0)
            {
                for (int n = 0; n < startupItems.Count; n++)
                {
                    SolutionEntityItem it = startupItems [n];
                    comboItems.AppendText(it.Name);
                    listStore.AppendValues(it, sol.MultiStartupItems.Contains(it), it.Name);
                    if (sol.StartupItem == it)
                    {
                        comboItems.Active = n;
                    }
                }
            }
            else
            {
                comboItems.AppendText(GettextCatalog.GetString("The solution does not contain any executable project"));
                comboItems.Active     = 0;
                comboItems.Sensitive  = false;
                radioMulti.Sensitive  = false;
                radioSingle.Sensitive = false;
            }

            radioSingle.Active = sol.SingleStartup;
            radioMulti.Active  = !sol.SingleStartup;
            UpdateButtons();

            crt.Toggled += OnItemToggled;
            treeItems.Selection.Changed += OnSelectionChanged;
        }
Ejemplo n.º 37
0
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem project, ConfigurationSelector configuration)
        {
            AspNetAppProject aspProject = project as AspNetAppProject;

            //get the config object and validate
            AspNetAppProjectConfiguration config = (AspNetAppProjectConfiguration)aspProject.GetConfiguration(configuration);

            if (config == null)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("Project configuration is invalid. Skipping CodeBehind member generation."));
                return(base.Build(monitor, project, configuration));
            }

            if (config.DisableCodeBehindGeneration)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("Skipping updating of CodeBehind partial classes, because this feature is disabled."));
                return(base.Build(monitor, project, configuration));
            }

            CodeBehindWriter writer = CodeBehindWriter.CreateForProject(monitor, aspProject);

            if (!writer.SupportsPartialTypes)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("The code generator for {0} does not support partial classes. Skipping CodeBehind member generation.",
                                          aspProject.LanguageBinding.Language));;
                return(base.Build(monitor, project, configuration));
            }

            //get the extension used for codebehind files
            string langExt = aspProject.LanguageBinding.GetFileName("a");

            langExt = langExt.Substring(1, langExt.Length - 1);

            List <CodeBehindWarning> errors = new List <CodeBehindWarning> ();

            monitor.Log.WriteLine(GettextCatalog.GetString("Generating CodeBehind members..."));

            bool updatedParseDb = false;

            //go over all the files generating members where necessary
            foreach (ProjectFile file in aspProject.Files)
            {
                WebSubtype type = AspNetAppProject.DetermineWebSubtype(file.FilePath);
                if (type != WebSubtype.WebForm && type != WebSubtype.WebControl && type != WebSubtype.MasterPage)
                {
                    continue;
                }

                //find the designer file
                ProjectFile designerFile = aspProject.Files.GetFile(file.Name + ".designer" + langExt);
                if (designerFile == null)
                {
                    aspProject.Files.GetFile(file.Name + ".Designer" + langExt);
                }
                if (designerFile == null)
                {
                    continue;
                }

                //only regenerate the designer class if it's older than the aspx (etc) file
                if (System.IO.File.GetLastWriteTimeUtc(designerFile.FilePath)
                    > System.IO.File.GetLastWriteTimeUtc(file.FilePath))
                {
                    continue;
                }

                //need parse DB to be up to date
                if (!updatedParseDb)
                {
                    updatedParseDb = true;
                    monitor.Log.Write(GettextCatalog.GetString("Waiting for project type database to finish updating..."));
                    ProjectDom dom = ProjectDomService.GetProjectDom(aspProject);
                    dom.ForceUpdate(true);
                    monitor.Log.WriteLine(GettextCatalog.GetString(" complete."));
                }

                //parse the ASP.NET file
                var parsedDocument = ProjectDomService.Parse(aspProject, file.FilePath) as AspNetParsedDocument;
                if (parsedDocument == null)
                {
                    continue;
                }

                var ccu = CodeBehind.GenerateCodeBehind(aspProject, designerFile.FilePath, parsedDocument, errors);
                if (ccu == null)
                {
                    continue;
                }

                writer.Write(ccu, designerFile.FilePath);
            }

            writer.WriteOpenFiles();

            //write out a friendly message aout what we did
            if (writer.WrittenCount > 0)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("{0} CodeBehind designer classes updated.", writer.WrittenCount));
            }
            else
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("No changes made to CodeBehind classes."));
            }

            //and construct and return a build result
            BuildResult baseResult = base.Build(monitor, project, configuration);

            foreach (CodeBehindWarning cbw in errors)
            {
                if (cbw.FileName != null)
                {
                    baseResult.AddWarning(cbw.FileName, cbw.Line, cbw.Column, null, cbw.WarningText);
                }
                else
                {
                    baseResult.AddWarning(cbw.WarningText);
                }
            }
            return(baseResult);
        }
Ejemplo n.º 38
0
        public BreakpointPropertiesDialog(Breakpoint bp, bool isNew)
        {
            this.Build();
            this.bp = bp;

            entryFile.Text = bp.FileName;
            entryLine.Text = bp.Line.ToString();

            if (!isNew)
            {
                entryFile.IsEditable = false;
                entryLine.IsEditable = false;
                entryFile.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryFile.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryLine.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryLine.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
            }

            if (string.IsNullOrEmpty(bp.ConditionExpression))
            {
                radioBreakAlways.Active = true;
            }
            else
            {
                entryCondition.Text = bp.ConditionExpression;
                if (bp.BreakIfConditionChanges)
                {
                    radioBreakChange.Active = true;
                }
                else
                {
                    radioBreakTrue.Active = true;
                }
            }

            spinHitCount.Value = bp.HitCount;

            if (bp.HitAction == HitAction.Break)
            {
                radioActionBreak.Active = true;
            }
            else
            {
                radioActionTrace.Active = true;
                entryTraceExpr.Text     = bp.TraceExpression;
            }

            Project project = IdeApp.Workspace.GetProjectContainingFile(bp.FileName);

            if (project != null)
            {
                // Check the startup project of the solution too, since the current project may be a library
                SolutionEntityItem startup = project.ParentSolution.StartupItem;
                boxConditionOptions.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.ConditionalBreakpoints) ||
                                                DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.ConditionalBreakpoints);
                boxAction.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.Tracepoints) ||
                                      DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.Tracepoints);
            }

            UpdateControls();
        }
Ejemplo n.º 39
0
 public override bool CanHandleItem(SolutionEntityItem item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 40
0
 protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
 {
     return(base.Build(monitor, entry, configuration));
 }
 public static BuildResult Compile(IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData, ItemCompileCallback callback)
 {
     return(Services.ProjectService.GetExtensionChain(item).Compile(monitor, item, buildData, callback));
 }
        public virtual DataCollection Serialize(object obj, ITypeSerializer handler)
        {
            if (obj is ProjectFile)
            {
                ProjectFile    pf   = (ProjectFile)obj;
                DataCollection data = handler.Serialize(obj);

                //Map the Content build action to the old FileCopy action if CopyToOutputDirectory is set
                if (pf.BuildAction == BuildAction.Content && pf.CopyToOutputDirectory != FileCopyMode.None)
                {
                    DataValue value = data ["buildaction"] as DataValue;
                    if (value != null)
                    {
                        data.Remove(value);
                        data.Add(new DataValue("buildaction", "FileCopy"));
                        data.Extract("copyToOutputDirectory");
                    }
                }
                // Don't store the resource id if it matches the default.
                if (pf.BuildAction == BuildAction.EmbeddedResource && pf.ResourceId != Path.GetFileName(pf.FilePath))
                {
                    data.Add(new DataValue("resource_id", pf.ResourceId));
                }
                return(data);
            }
            else if (obj is SolutionEntityItem)
            {
                DotNetProject project = obj as DotNetProject;
                if (project != null)
                {
                    foreach (DotNetProjectConfiguration config in project.Configurations)
                    {
                        config.ExtendedProperties ["Build/target"] = project.CompileTarget.ToString();
                    }
                }
                DataCollection     data = handler.Serialize(obj);
                SolutionEntityItem item = (SolutionEntityItem)obj;
                if (item.DefaultConfiguration != null)
                {
                    DataItem confItem = data ["Configurations"] as DataItem;
                    if (confItem != null)
                    {
                        confItem.UniqueNames = true;
                        if (item.ParentSolution != null)
                        {
                            confItem.ItemData.Add(new DataValue("active", item.ParentSolution.DefaultConfigurationId));
                        }
                    }
                }
                if (project != null)
                {
                    data.Extract("targetFramework");
                    data.Add(new DataValue("targetFramework", project.TargetFramework.Id.ToLegacyIdString()));
                }
                WriteItems(handler, (SolutionEntityItem)obj, data);
                return(data);
            }
            else if (obj is ProjectReference)
            {
                ProjectReference pref  = (ProjectReference)obj;
                DataCollection   data  = handler.Serialize(obj);
                string           refto = pref.Reference;
                if (pref.ReferenceType == ReferenceType.Assembly)
                {
                    string basePath = Path.GetDirectoryName(handler.SerializationContext.BaseFile);
                    refto = FileService.AbsoluteToRelativePath(basePath, refto);
                }
                else if (pref.ReferenceType == ReferenceType.Package && pref.LoadedReference != null)
                {
                    refto = pref.LoadedReference;
                }

                data.Add(new DataValue("refto", refto));
                return(data);
            }
            return(handler.Serialize(obj));
        }
Ejemplo n.º 43
0
        public BreakpointPropertiesDialog(Breakpoint bp, bool isNew)
        {
            this.Build();

            this.isNew = isNew;
            this.bp    = bp;

            spinColumn.Adjustment.Upper = int.MaxValue;
            spinColumn.Adjustment.Lower = 1;
            spinLine.Adjustment.Upper   = int.MaxValue;
            spinLine.Adjustment.Lower   = 1;

            if (bp is FunctionBreakpoint)
            {
                FunctionBreakpoint fb = (FunctionBreakpoint)bp;

                labelFileFunction.LabelProp = GettextCatalog.GetString("Function:");

                if (fb.ParamTypes != null)
                {
                    // FIXME: support non-C# syntax based on fb.Language
                    entryFileFunction.Text = fb.FunctionName + " (" + string.Join(", ", fb.ParamTypes) + ")";
                }
                else
                {
                    entryFileFunction.Text = fb.FunctionName;
                }

                if (!isNew)
                {
                    // We don't use ".Sensitive = false" because we want the user to be able to select & copy the text.
                    entryFileFunction.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                    entryFileFunction.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                    entryFileFunction.IsEditable = false;
                }

                // Function breakpoints only support breaking on the first line
                hboxLineColumn.Destroy();
                labelLine.Destroy();
                table1.NRows--;
            }
            else
            {
                labelFileFunction.LabelProp = GettextCatalog.GetString("File:");
                entryFileFunction.Text      = ((Breakpoint)bp).FileName;

                // We don't use ".Sensitive = false" because we want the user to be able to select & copy the text.
                entryFileFunction.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryFileFunction.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryFileFunction.IsEditable = false;

                //spinColumn.Value = bp.Column;
                spinLine.Value = bp.Line;

                if (!isNew)
                {
                    spinColumn.IsEditable = false;
                    spinColumn.Sensitive  = false;
                    spinLine.IsEditable   = false;
                    spinLine.Sensitive    = false;
                }

                // Note: We hide the column spin button for now because we don't support it yet
                hboxColumn.Hide();
            }

            if (string.IsNullOrEmpty(bp.ConditionExpression))
            {
                radioBreakAlways.Active = true;
            }
            else
            {
                entryCondition.Text = bp.ConditionExpression;
                if (bp.BreakIfConditionChanges)
                {
                    radioBreakChange.Active = true;
                }
                else
                {
                    radioBreakTrue.Active = true;
                }
            }

            spinHitCount.Value = bp.HitCount;

            if (bp.HitAction == HitAction.Break)
            {
                radioActionBreak.Active = true;
            }
            else
            {
                radioActionTrace.Active = true;
                entryTraceExpr.Text     = bp.TraceExpression;
            }

            Project project = null;

            if (!string.IsNullOrEmpty(bp.FileName))
            {
                project = IdeApp.Workspace.GetProjectContainingFile(bp.FileName);
            }

            if (project != null)
            {
                // Check the startup project of the solution too, since the current project may be a library
                SolutionEntityItem startup = project.ParentSolution.StartupItem;
                boxConditionOptions.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.ConditionalBreakpoints) ||
                                                DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.ConditionalBreakpoints);
                boxAction.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.Tracepoints) ||
                                      DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.Tracepoints);
            }

            UpdateControls();
        }
        string GetSelectedConfiguration(SolutionEntityItem item)
        {
            var entry = configuration.GetEntryForItem(item);

            return(entry != null ? entry.ItemConfiguration : (item.DefaultConfiguration != null ? item.DefaultConfiguration.Id : ""));
        }
Ejemplo n.º 45
0
        public void InitializeItem(SolutionItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionEntityItem 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;
                    }
                    if (desc.ProjectReference.ReferenceType == ReferenceType.Project)
                    {
                        string referencedProjectName = ReplaceParameters(desc.ProjectReference.Reference, substitution, projectCreateInformation);
                        var    parsedReference       = ProjectReference.RenameReference(desc.ProjectReference, referencedProjectName);
                        dnp.References.Add(parsedReference);
                    }
                    else
                    {
                        dnp.References.Add(desc.ProjectReference);
                    }
                }
            }

            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);
                }
            }
        }
 public override bool CanHandleItem(SolutionEntityItem item)
 {
     return((item is DotNetProject) && ((DotNetProject)item).LanguageName == language);
 }
Ejemplo n.º 47
0
 public abstract bool CanHandleItem(SolutionEntityItem item);
 public override bool CanHandleItem(SolutionEntityItem item)
 {
     return(ItemType != null && ItemType.IsAssignableFrom(item.GetType()));
 }
 protected override BuildResult Compile(IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
 {
     return(base.Compile(monitor, item, buildData));
 }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
        {
            var proj = item as MonoMacProject;

            if (proj == null || proj.CompileTarget != CompileTarget.Exe)
            {
                return(base.Build(monitor, item, configuration));
            }

            var conf   = (MonoMacProjectConfiguration)configuration.GetConfiguration(item);
            var resDir = conf.AppDirectory.Combine("Contents", "Resources");
            var appDir = conf.AppDirectory;

            //make sure the codebehind files are updated before building
            var res = MacBuildUtilities.UpdateCodeBehind(monitor, proj.CodeBehindGenerator, proj.Files);

            if (res.ErrorCount > 0)
            {
                return(res);
            }

            res = res.Append(base.Build(monitor, item, configuration));
            if (res.ErrorCount > 0)
            {
                return(res);
            }

            //copy exe, mdb, refs, copy-to-output, Content files to Resources
            var filesToCopy = GetCopyFiles(proj, configuration, conf).Where(NeedsBuilding).ToList();

            if (filesToCopy.Count > 0)
            {
                monitor.BeginTask("Copying resource files to app bundle", filesToCopy.Count);
                foreach (var f in filesToCopy)
                {
                    f.EnsureOutputDirectory();
                    File.Copy(f.Input, f.Output, true);
                    monitor.Log.WriteLine("Copied {0}", f.Output.ToRelative(appDir));
                    monitor.Step(1);
                }
                monitor.EndTask();
            }

            if (!PropertyService.IsMac)
            {
                res.AddWarning("Cannot compile xib files on non-Mac platforms");
            }
            else
            {
                //Interface Builder files
                if (res.Append(MacBuildUtilities.CompileXibFiles(monitor, proj.Files, resDir)).ErrorCount > 0)
                {
                    return(res);
                }
            }

            //info.plist
            var plistOut  = conf.AppDirectory.Combine("Contents", "Info.plist");
            var appInfoIn = proj.Files.GetFile(proj.BaseDirectory.Combine("Info.plist"));

            if (new FilePair(proj.FileName, plistOut).NeedsBuilding() ||
                (appInfoIn != null && new FilePair(appInfoIn.FilePath, plistOut).NeedsBuilding()))
            {
                if (res.Append(MergeInfoPlist(monitor, proj, conf, appInfoIn, plistOut)).ErrorCount > 0)
                {
                    return(res);
                }
            }

            //launch script
            var ls = conf.LaunchScript;

            if (!File.Exists(ls))
            {
                if (!Directory.Exists(ls.ParentDirectory))
                {
                    Directory.CreateDirectory(ls.ParentDirectory);
                }
                var src = AddinManager.CurrentAddin.GetFilePath("MonoMacLaunchScript.sh");
                File.Copy(src, ls, true);
                var fi = new UnixFileInfo(ls);
                fi.FileAccessPermissions |= FileAccessPermissions.UserExecute
                                            | FileAccessPermissions.GroupExecute | FileAccessPermissions.OtherExecute;
            }

            //pkginfo
            var pkgInfo = conf.AppDirectory.Combine("Contents", "PkgInfo");

            if (!File.Exists(pkgInfo))
            {
                using (var f = File.OpenWrite(pkgInfo))
                    f.Write(new byte [] { 0X41, 0X50, 0X50, 0X4C, 0x3f, 0x3f, 0x3f, 0x3f }, 0, 8);                     // "APPL???"
            }
            return(res);
        }
Ejemplo n.º 51
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);
        }
        protected override BuildResult Compile(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
        {
#if DEBUG
            monitor.Log.WriteLine("MonoGame Extension Compile Called");
#endif
            try
            {
                var cfg  = buildData.Configuration as MonoGameContentProjectConfiguration;
                var proj = item as MonoGameContentProject;
                if (proj == null || cfg == null)
                {
                    monitor.Log.WriteLine("Compiling for Unknown MonoGame Project");
                    return(base.Compile(monitor, item, buildData));
                }
                monitor.Log.WriteLine("Detected {0} MonoGame Platform", cfg.MonoGamePlatform);
                var result  = new BuildResult();
                var manager = new PipelineManager(proj.BaseDirectory.FullPath,
                                                  Path.Combine(buildData.Configuration.OutputDirectory, cfg.MonoGamePlatform),
                                                  buildData.Configuration.IntermediateOutputDirectory);

                manager.Logger   = new MonitorBuilder(monitor, result);
                manager.Platform = (TargetPlatform)Enum.Parse(typeof(TargetPlatform), cfg.MonoGamePlatform);
                try {
                    foreach (var pr in proj.ParentSolution.GetAllProjects())
                    {
                        if (pr is DotNetAssemblyProject)
                        {
                            var dot = pr as DotNetAssemblyProject;
                            foreach (var r in dot.References)
                            {
                                if (r.Package.Name == "monogame-contentpipeline")
                                {
                                    var output = dot.GetOutputFileName(buildData.ConfigurationSelector).FullPath;
                                    monitor.Log.WriteLine("Adding {0} to Content Pipeline Assembly List", output);
                                    manager.AddAssembly(output);
                                    proj.Manager.AddAssembly(output);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    result.AddWarning(string.Format("Problem processing Content Extensions {0}", ex.Message));
                }

                var dict = new Microsoft.Xna.Framework.Content.Pipeline.OpaqueDataDictionary();
                if (cfg != null)
                {
                    if (cfg.XnaCompressContent.ToLowerInvariant() == "true")
                    {
                        // tell the manager to compress the output
                    }
                }
                foreach (var file in proj.Files)
                {
                    if (file.BuildAction == "Compile")
                    {
                        try
                        {
                            dict.Clear();
                            foreach (object key in file.ExtendedProperties.Keys)
                            {
                                string k = key as string;
                                if (k != null && k.StartsWith("ProcessorParameters_"))
                                {
                                    if (!dict.ContainsKey(k.Replace("ProcessorParameters_", String.Empty)))
                                    {
                                        dict.Add(k.Replace("ProcessorParameters_", String.Empty), file.ExtendedProperties[k]);
                                    }
                                    else
                                    {
                                        dict[k.Replace("ProcessorParameters_", String.Empty)] = file.ExtendedProperties[k];
                                    }
                                }
                            }

                            // check if the file has changed and rebuild if required.
                            manager.BuildContent(file.FilePath.FullPath,
                                                 null,
                                                 file.ExtendedProperties.Contains("Importer") ? (string)file.ExtendedProperties["Importer"] : null,
                                                 file.ExtendedProperties.Contains("Processor") ? (string)file.ExtendedProperties["Processor"] : null,
                                                 dict);
                        }
                        catch (Exception ex)
                        {
                            monitor.Log.WriteLine(ex.ToString());
                            result.AddError(ex.Message);
                        }
                    }
                }
                return(result);
            }
            finally
            {
#if DEBUG
                monitor.Log.WriteLine("MonoGame Extension Compile Ended");
#endif
            }
        }
Ejemplo n.º 53
0
 List <ProjectReference> GetProjectReferences(SolutionEntityItem solutionItem)
 {
     return(solutionItem.Items.OfType <ProjectReference> ()
            .Where(item => item.ReferenceType == ReferenceType.Project)
            .ToList());
 }
Ejemplo n.º 54
0
 public ProjectOptionsDialog(Gtk.Window parentWindow, SolutionEntityItem project) : base(parentWindow, project)
 {
     this.Title = GettextCatalog.GetString("Project Options") + " - " + project.Name;
 }
Ejemplo n.º 55
0
        public WorkspaceItemCreatedInformation CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            WorkspaceItem workspaceItem = null;

            if (string.IsNullOrEmpty(type))
            {
                workspaceItem = new Solution();
            }
            else
            {
                Type workspaceItemType = addin.GetType(type, false);
                if (workspaceItemType != null)
                {
                    workspaceItem = Activator.CreateInstance(workspaceItemType) as WorkspaceItem;
                }

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

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

            workspaceItem.SetLocation(projectCreateInformation.SolutionPath, workspaceItem.Name);

            ProjectCreateInformation localProjectCI;

            if (!string.IsNullOrEmpty(directory) && directory != ".")
            {
                localProjectCI = new ProjectCreateInformation(projectCreateInformation);

                localProjectCI.SolutionPath    = Path.Combine(localProjectCI.SolutionPath, directory);
                localProjectCI.ProjectBasePath = Path.Combine(localProjectCI.ProjectBasePath, directory);

                if (!Directory.Exists(localProjectCI.SolutionPath))
                {
                    Directory.CreateDirectory(localProjectCI.SolutionPath);
                }

                if (!Directory.Exists(localProjectCI.ProjectBasePath))
                {
                    Directory.CreateDirectory(localProjectCI.ProjectBasePath);
                }
            }
            else
            {
                localProjectCI = projectCreateInformation;
            }

            var workspaceItemCreatedInfo = new WorkspaceItemCreatedInformation(workspaceItem);

            Solution solution = workspaceItem as Solution;

            if (solution != null)
            {
                for (int i = 0; i < entryDescriptors.Count; i++)
                {
                    ProjectCreateInformation entryProjectCI;
                    var entry = entryDescriptors[i] as ICustomProjectCIEntry;
                    if (entry != null)
                    {
                        entryProjectCI = entry.CreateProjectCI(localProjectCI);
                    }
                    else
                    {
                        entryProjectCI = localProjectCI;
                    }

                    var solutionItemDesc = entryDescriptors[i];

                    SolutionEntityItem info = solutionItemDesc.CreateItem(entryProjectCI, defaultLanguage);
                    if (info == null)
                    {
                        continue;
                    }

                    solutionItemDesc.InitializeItem(solution.RootFolder, entryProjectCI, defaultLanguage, info);

                    IConfigurationTarget configurationTarget = info 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);
                            }
                        }
                    }

                    if ((info is Project) && (solutionItemDesc is ProjectDescriptor))
                    {
                        workspaceItemCreatedInfo.AddPackageReferenceForCreatedProject((Project)info, (ProjectDescriptor)solutionItemDesc);
                    }
                    solution.RootFolder.Items.Add(info);
                    if (startupProject == info.Name)
                    {
                        solution.StartupItem = info;
                    }
                }
            }

            if (!workspaceItem.FileFormat.CanWrite(workspaceItem))
            {
                // The default format can't write solutions of this type. Find a compatible format.
                FileFormat f = IdeApp.Services.ProjectService.FileFormats.GetFileFormatsForObject(workspaceItem).First();
                workspaceItem.ConvertToFormat(f, true);
            }

            return(workspaceItemCreatedInfo);
        }
Ejemplo n.º 56
0
 public virtual void SaveProject(IProgressMonitor monitor, SolutionEntityItem item, MSBuildProject project)
 {
 }
Ejemplo n.º 57
0
        public void InitializeItem(SolutionItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionEntityItem 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;
            }

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

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

            var dnp = project as DotNetProject;

            if (dnp != null)
            {
                if (policyParent.ParentSolution != null && !policyParent.ParentSolution.FileFormat.SupportsFramework(dnp.TargetFramework))
                {
                    SetClosestSupportedTargetFramework(policyParent.ParentSolution.FileFormat, dnp);
                }
                foreach (ProjectReference projectReference in references)
                {
                    dnp.References.Add(projectReference);
                }
            }

            foreach (SingleFileDescriptionTemplate resourceTemplate in resources)
            {
                try {
                    ProjectFile projectFile = new ProjectFile(resourceTemplate.SaveFile(policyParent, project, defaultLanguage, project.BaseDirectory, null));
                    projectFile.BuildAction = BuildAction.EmbeddedResource;
                    project.Files.Add(projectFile);
                } catch (Exception ex) {
                    MessageService.ShowException(ex, GettextCatalog.GetString("File {0} could not be written.", resourceTemplate.Name));
                    LoggingService.LogError(GettextCatalog.GetString("File {0} could not be written.", resourceTemplate.Name), ex);
                }
            }

            foreach (FileDescriptionTemplate fileTemplate in files)
            {
                try {
                    fileTemplate.AddToProject(policyParent, project, defaultLanguage, project.BaseDirectory, null);
                } catch (Exception ex) {
                    MessageService.ShowException(ex, GettextCatalog.GetString("File {0} could not be written.", fileTemplate.Name));
                    LoggingService.LogError(GettextCatalog.GetString("File {0} could not be written.", fileTemplate.Name), ex);
                }
            }
        }
        protected override BuildResult Build(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
        {
#if DEBUG
            monitor.Log.WriteLine("MonoGame Extension Build Called");
#endif
            try
            {
                return(base.Build(monitor, item, configuration));
            }
            finally
            {
#if DEBUG
                monitor.Log.WriteLine("MonoGame Extension Build Ended");
#endif
            }
        }
        public virtual void Deserialize(object obj, ITypeSerializer handler, DataCollection data)
        {
            if (obj is ProjectFile)
            {
                ProjectFile pf = (ProjectFile)obj;

                //Map the old FileCopy action to the Content BuildAction with CopyToOutputDirectory set to "always"
                //BuildActionDataType handles mapping the BuildAction to "Content"
                DataValue value      = data ["buildaction"] as DataValue;
                bool      isFileCopy = value != null && value.Value == "FileCopy";

                DataValue resourceId = data.Extract("resource_id") as DataValue;

                handler.Deserialize(obj, data);
                if (isFileCopy)
                {
                    pf.CopyToOutputDirectory = FileCopyMode.Always;
                }

                if (resourceId != null)
                {
                    pf.ResourceId = resourceId.Value;
                }
            }
            else if (obj is SolutionEntityItem)
            {
                DataValue ac       = null;
                DataItem  confItem = data ["Configurations"] as DataItem;
                if (confItem != null)
                {
                    ac = (DataValue)confItem.ItemData.Extract("active");
                }

                DataItem items = data.Extract("Items") as DataItem;
                if (items != null)
                {
                    ReadItems(handler, (SolutionEntityItem)obj, items);
                }

                handler.Deserialize(obj, data);
                if (ac != null)
                {
                    SolutionEntityItem item = (SolutionEntityItem)obj;
                    item.DefaultConfigurationId = ac.Value;
                }
                DotNetProject np = obj as DotNetProject;
                if (np != null)
                {
                    // Import the framework version
                    TargetFrameworkMoniker fx = null;
                    DataValue vfx             = data["targetFramework"] as DataValue;
                    if (vfx != null)
                    {
                        fx = TargetFrameworkMoniker.Parse(vfx.Value);
                    }
                    else
                    {
                        vfx = data ["clr-version"] as DataValue;
                        if (vfx != null && vfx.Value == "Net_2_0")
                        {
                            fx = TargetFrameworkMoniker.NET_2_0;
                        }
                        else if (vfx != null && vfx.Value == "Net_1_1")
                        {
                            fx = TargetFrameworkMoniker.NET_1_1;
                        }
                    }
                    if (fx != null)
                    {
                        np.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(fx);
                    }

                    // Get the compile target from one of the configurations
                    if (np.Configurations.Count > 0)
                    {
                        np.CompileTarget = (CompileTarget)Enum.Parse(typeof(CompileTarget), (string)np.Configurations [0].ExtendedProperties ["Build/target"]);
                    }
                }
            }
            else if (obj is ProjectReference)
            {
                ProjectReference pref  = (ProjectReference)obj;
                DataValue        refto = data.Extract("refto") as DataValue;
                handler.Deserialize(obj, data);
                if (refto != null)
                {
                    pref.Reference = refto.Value;
                    if (pref.ReferenceType == ReferenceType.Assembly)
                    {
                        string basePath = Path.GetDirectoryName(handler.SerializationContext.BaseFile);
                        pref.Reference = FileService.RelativeToAbsolutePath(basePath, pref.Reference);
                    }
                }
            }
            else
            {
                handler.Deserialize(obj, data);
            }
        }
 protected override IEnumerable <ExecutionTarget> GetExecutionTargets(SolutionEntityItem item, ConfigurationSelector configuration)
 {
     return(ExecutionTargets);
 }