Exemple #1
0
        private int RemoveProjectToProjectReferenceAlternatives(string framework, string reference)
        {
            int numberOfRemovedRefs = 0;

            foreach (var r in GetIncludeAlternativesForRemoval(reference))
            {
                foreach (var existingItem in ProjectRootElement.FindExistingItemsWithCondition(framework, r))
                {
                    ProjectElementContainer itemGroup = existingItem.Parent;
                    itemGroup.RemoveChild(existingItem);
                    if (itemGroup.Children.Count == 0)
                    {
                        itemGroup.Parent.RemoveChild(itemGroup);
                    }

                    numberOfRemovedRefs++;
                    Reporter.Output.WriteLine(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, r));
                }
            }

            if (numberOfRemovedRefs == 0)
            {
                Reporter.Output.WriteLine(string.Format(
                                              CommonLocalizableStrings.ProjectReferenceCouldNotBeFound,
                                              reference));
            }

            return(numberOfRemovedRefs);
        }
 public static bool HasExistingItemWithCondition(this ProjectRootElement root, string framework, string include)
 {
     return(root.FindExistingItemsWithCondition(framework, include).Count() != 0);
 }