diff options
author | Matt Ward <ward.matt@gmail.com> | 2014-12-15 13:24:00 +0300 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2014-12-15 13:39:39 +0300 |
commit | dce791ef396f0c1f606f2da8ffcec6a7965ff521 (patch) | |
tree | bbd351f8f1b190dc2abe8e4ddaa4d94b2d94ae8e /main | |
parent | 87e4bf89aeeb062a2dbbcdc60cf6b4d6fb524640 (diff) |
[Core] Allow Target and Error elements to be read from MSBuild project
Allow Target elements in an MSBuild project to be read:
<Target Name="MyTarget" BeforeTargets="PrepareForBuild">
</Target>
Allow Error tasks inside a Target element to be read:
<Target Name="MyTarget" BeforeTargets="PrepareForBuild">
<Error Condition="!Exists(MyTargets.targets')"
Text="$([System.String]::Format('$(ErrorText)', 'MyTargets.targets'))" />
</Target>
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProject.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProject.cs index 2976287a16..bc122951c5 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProject.cs @@ -418,6 +418,13 @@ namespace MonoDevelop.Projects.Formats.MSBuild elemCache.Remove (grp.Element); grp.Element.ParentNode.RemoveChild (grp.Element); } + + public IEnumerable<MSBuildTarget> Targets { + get { + foreach (XmlElement elem in doc.DocumentElement.SelectNodes ("tns:Target", XmlNamespaceManager)) + yield return new MSBuildTarget (elem); + } + } } public class MSBuildObject @@ -906,6 +913,48 @@ namespace MonoDevelop.Projects.Formats.MSBuild } } + public class MSBuildTarget: MSBuildObject + { + public MSBuildTarget (XmlElement elem): base (elem) + { + } + + public string Name { + get { return EvaluatedElement.GetAttribute ("Name"); } + set { Element.SetAttribute ("Name", value); } + } + + public IEnumerable<MSBuildTask> Tasks { + get { + foreach (XmlNode node in Element.ChildNodes) { + var elem = node as XmlElement; + if (MSBuildTask.IsTask (elem)) + yield return new MSBuildTask (elem); + } + } + } + } + + public class MSBuildTask: MSBuildObject + { + public static bool IsTask (XmlElement elem) + { + if (elem == null) + return false; + + return elem.LocalName == "Error"; + } + + public MSBuildTask (XmlElement elem): base (elem) + { + } + + public string Name { + get { return EvaluatedElement.GetAttribute ("Name"); } + set { Element.SetAttribute ("Name", value); } + } + } + public class MSBuildEvaluationContext: IExpressionContext { Dictionary<string,string> properties = new Dictionary<string, string> (); |