public static ProjectItemGroupElement FindUniformOrCreateItemGroupWithCondition(this ProjectRootElement root, string projectItemElementType, string framework) { var lastMatchingItemGroup = FindExistingUniformItemGroupWithCondition(root, projectItemElementType, framework); if (lastMatchingItemGroup != null) { return(lastMatchingItemGroup); } ProjectItemGroupElement ret = root.CreateItemGroupElement(); string condStr; if (TryGetFrameworkConditionString(framework, out condStr)) { ret.Condition = condStr; } root.InsertAfterChild(ret, root.LastItemGroup()); return(ret); }