public MSBuildItemGroup AddNewItemGroup() { AssertCanModify(); var group = new MSBuildItemGroup(); MSBuildObject refNode = null; var lastGroup = ItemGroups.LastOrDefault(); if (lastGroup != null) { refNode = lastGroup; } else { var g = PropertyGroups.LastOrDefault(); if (g != null) { refNode = g; } } group.ParentNode = this; if (refNode != null) { ChildNodes = ChildNodes.Insert(ChildNodes.IndexOf(refNode) + 1, group); } else { ChildNodes = ChildNodes.Add(group); } group.ResetIndent(true); NotifyChanged(); return(group); }
internal override void ReadChildElement(MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup(); break; case "PropertyGroup": ob = new MSBuildPropertyGroup(); break; case "ImportGroup": ob = new MSBuildImportGroup(); break; case "Import": ob = new MSBuildImport(); break; case "Target": ob = new MSBuildTarget(); break; case "Choose": ob = new MSBuildChoose(); break; case "ProjectExtensions": ob = new MSBuildProjectExtensions(); break; default: ob = new MSBuildXmlElement(); break; } if (ob != null) { ob.ParentNode = this; ob.Read(reader); ChildNodes = ChildNodes.Add(ob); } else { base.ReadChildElement(reader); } }
void Evaluate(ProjectInfo project, MSBuildEvaluationContext context, MSBuildItemGroup items) { bool conditionIsTrue = true; if (!string.IsNullOrEmpty(items.Condition)) { conditionIsTrue = SafeParseAndEvaluate(project, context, items.Condition); } foreach (var item in items.Items) { var include = context.EvaluateString(item.Include); var exclude = context.EvaluateString(item.Exclude); var it = CreateEvaluatedItem(context, project, project.Project, item, include); var trueCond = conditionIsTrue && (string.IsNullOrEmpty(it.Condition) || SafeParseAndEvaluate(project, context, it.Condition)); var excludeRegex = !string.IsNullOrEmpty(exclude) ? new Regex(ExcludeToRegex(exclude)) : null; if (it.Include.IndexOf(';') == -1) { AddItem(project, context, item, it, it.Include, excludeRegex, trueCond); } else { foreach (var inc in it.Include.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { AddItem(project, context, item, it, inc, excludeRegex, trueCond); } } } }
public void AddItem(MSBuildItem it) { if (string.IsNullOrEmpty(it.Name)) { throw new InvalidOperationException("Item doesn't have a name"); } MSBuildItemGroup grp = FindBestGroupForItem(it.Name); grp.AddItem(it); }
internal override void ReadChildElement (MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup (); break; case "PropertyGroup": ob = new MSBuildPropertyGroup (); break; case "ImportGroup": ob = new MSBuildImportGroup (); break; case "Choose": ob = new MSBuildChoose (); break; default: ob = new MSBuildXmlElement (); break; } if (ob != null) { ob.ParentNode = this; ob.Read (reader); ChildNodes = ChildNodes.Add (ob); } else reader.Read (); }
public void AddItem(MSBuildItem it, MSBuildItem beforeItem) { if (string.IsNullOrEmpty(it.Name)) { throw new InvalidOperationException("Item doesn't have a name"); } if (beforeItem != null) { var group = beforeItem.ParentNode as MSBuildItemGroup; if (group != null) { group.AddItem(it, beforeItem); return; } } MSBuildItemGroup grp = FindBestGroupForItem(it); grp.AddItem(it); }
internal override void ReadChildElement(MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup(); break; case "PropertyGroup": ob = new MSBuildPropertyGroup(); break; case "ImportGroup": ob = new MSBuildImportGroup(); break; case "Choose": ob = new MSBuildChoose(); break; default: ob = new MSBuildXmlElement(); break; } ob.ParentNode = this; ob.Read(reader); ChildNodes = ChildNodes.Add(ob); }
MSBuildItemGroup FindBestGroupForItem(MSBuildItem newItem) { string groupId = GetBestGroupId(newItem); MSBuildItemGroup group; if (bestGroups == null) { bestGroups = new Dictionary <string, MSBuildItemGroup> (); } else { if (bestGroups.TryGetValue(groupId, out group)) { return(group); } } MSBuildItemGroup insertBefore = null; foreach (MSBuildItemGroup grp in ItemGroups) { foreach (MSBuildItem it in grp.Items) { if (ShouldAddItemToGroup(it, newItem)) { bestGroups [groupId] = grp; return(grp); } else if (insertBefore == null && ShouldInsertItemGroupBefore(it, newItem)) { insertBefore = grp; } } } group = AddNewItemGroup(insertBefore); bestGroups [groupId] = group; return(group); }
internal override void ReadChildElement(MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup(); break; case "PropertyGroup": ob = new MSBuildPropertyGroup(); break; } if (ob != null) { ob.ParentNode = this; ob.Read(reader); ChildNodes = ChildNodes.Add(ob); return; } var task = new MSBuildTask(); task.ParentNode = this; task.Read(reader); ChildNodes = ChildNodes.Add(task); }
public MSBuildItem AddNewItem(string name, string include) { MSBuildItemGroup grp = FindBestGroupForItem(name); return(grp.AddNewItem(name, include)); }
public MSBuildItemGroup AddNewItemGroup () { AssertCanModify (); var group = new MSBuildItemGroup (); MSBuildObject refNode = null; var lastGroup = ItemGroups.LastOrDefault (); if (lastGroup != null) refNode = lastGroup; else { var g = PropertyGroups.LastOrDefault (); if (g != null) refNode = g; } group.ParentNode = this; if (refNode != null) ChildNodes = ChildNodes.Insert (ChildNodes.IndexOf (refNode) + 1, group); else ChildNodes = ChildNodes.Add (group); group.ResetIndent (true); NotifyChanged (); return group; }
internal override void ReadChildElement (MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup (); break; case "PropertyGroup": ob = new MSBuildPropertyGroup (); break; } if (ob != null) { ob.ParentNode = this; ob.Read (reader); ChildNodes = ChildNodes.Add (ob); return; } var task = new MSBuildTask (); task.ParentNode = this; task.Read (reader); ChildNodes = ChildNodes.Add (task); }
void Evaluate (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItemGroup items) { bool conditionIsTrue = true; if (!string.IsNullOrEmpty (items.Condition)) conditionIsTrue = SafeParseAndEvaluate (project, context, items.Condition); foreach (var item in items.Items) { var include = context.EvaluateString (item.Include); var exclude = context.EvaluateString (item.Exclude); var it = CreateEvaluatedItem (context, project, project.Project, item, include); var trueCond = conditionIsTrue && (string.IsNullOrEmpty (it.Condition) || SafeParseAndEvaluate (project, context, it.Condition)); var excludeRegex = !string.IsNullOrEmpty (exclude) ? new Regex (ExcludeToRegex (exclude)) : null; if (it.Include.IndexOf (';') == -1) AddItem (project, context, item, it, it.Include, excludeRegex, trueCond); else { foreach (var inc in it.Include.Split (new [] {';'}, StringSplitOptions.RemoveEmptyEntries)) AddItem (project, context, item, it, inc, excludeRegex, trueCond); } } }