diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2015-06-02 16:52:55 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2015-06-02 16:52:55 +0300 |
commit | 4bec0daaefac12d3a4bc44f32ecd8d97bf1ada93 (patch) | |
tree | 7d2ffa438927f7af6a549cf23e3c27f2a6b7ebf4 /main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs | |
parent | 3f673215d714d480084a971957e3c60bdb07f339 (diff) |
[Core] Project model improvements
Implemented some new methods. Added a RunTarget overload that allows specifying
properties and items to get as result of the evaluation.
Added a Build overload that allows specifying global properties to use.
Implemented OnGetSupportedTarget in the Project class, which gets the list of
targets from the msbuild builder.
Diffstat (limited to 'main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs index 0157320709..17ea3089e8 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs @@ -41,6 +41,7 @@ using Mono.Addins; using System.Linq; using MonoDevelop.Core.Instrumentation; using MonoDevelop.Core.ProgressMonitoring; +using System.Runtime.Remoting.Messaging; namespace MonoDevelop.Projects.Formats.MSBuild { @@ -287,9 +288,35 @@ namespace MonoDevelop.Projects.Formats.MSBuild } } } + + public string[] GetSupportedTargets () + { + if (UseMSBuildEngineForItem (Item, ConfigurationSelector.Default)) { + SolutionEntityItem item = (SolutionEntityItem) Item; + var configs = GetConfigurations (item, ConfigurationSelector.Default); + RemoteProjectBuilder builder = GetProjectBuilder (); + return builder.GetSupportedTargets (configs); + } else + return new string[0]; + } public override BuildResult RunTarget (IProgressMonitor monitor, string target, ConfigurationSelector configuration) { + var r = RunTarget (monitor, target, configuration, null); + if (r == null) + return null; + return r.BuildResult; + } + + public override TargetEvaluationResult RunTarget (IProgressMonitor monitor, string target, ConfigurationSelector configuration, TargetEvaluationContext context) + { + if (context == null) { + context = new TargetEvaluationContext (); + var bc = CallContext.GetData ("MonoDevelop.Projects.ProjectOperationContext") as ProjectOperationContext; + if (bc != null) + context.CopyFrom (bc); + } + if (UseMSBuildEngineForItem (Item, configuration)) { SolutionEntityItem item = Item as SolutionEntityItem; if (item != null) { @@ -309,7 +336,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild MSBuildResult result; try { - result = builder.Run (configs, logWriter, MSBuildProjectService.DefaultMSBuildVerbosity, new[] { target }, null, null); + result = builder.Run (configs, logWriter, MSBuildProjectService.DefaultMSBuildVerbosity, new[] { target }, context.ItemsToEvaluate.ToArray(), context.PropertiesToEvaluate.ToArray (), context.GlobalProperties); } finally { t1.End (); if (t2 != null) @@ -331,14 +358,16 @@ namespace MonoDevelop.Projects.Formats.MSBuild IsWarning = err.IsWarning }); } - return br; + + return new TargetEvaluationResult (br, result.Items.Values.SelectMany (i => i), result.Properties); } } else { CleanupProjectBuilder (); if (Item is DotNetProject) { MD1DotNetProjectHandler handler = new MD1DotNetProjectHandler ((DotNetProject)Item); - return handler.RunTarget (monitor, target, configuration); + var br = handler.RunTarget (monitor, target, configuration); + return new TargetEvaluationResult (br); } } return null; |