Exemplo n.º 1
0
        public static IProjectRootElement AddCsWinRTReferenceAndComponentProperty(this IProjectRootElement projectRootElement, BaselineProject baselineProject)
        {
            if (baselineProject.OutputType == ProjectOutputType.WinMdObj)
            {
                var topLevelPropGroup = MSBuildHelpers.GetOrCreateTopLevelPropertyGroup(baselineProject, projectRootElement);
                topLevelPropGroup.AddProperty(MSBuildFacts.CsWinRTComponentName, "true");

                var packageReferenceItemGroup = projectRootElement.ItemGroups.Where(ig => ig.Items.Any(i => i.ItemType == MSBuildFacts.MSBuildPackageReferenceName))
                                                .FirstOrDefault() ?? projectRootElement.AddItemGroup();
                AddPackageReferenceElement(packageReferenceItemGroup, MSBuildFacts.CsWinRTPackageReference.Name, MSBuildFacts.CsWinRTPackageReference.Version);
            }

            return(projectRootElement);
        }
Exemplo n.º 2
0
        private void AddItemRemovesForIntroducedItems()
        {
            var introducedItems = _differs.Values
                                  .SelectMany(
                differ => differ.GetItemsDiff()
                .Where(diff => Facts.GlobbedItemTypes.Contains(diff.ItemType, StringComparer.OrdinalIgnoreCase))
                .SelectMany(diff => diff.IntroducedItems))
                                  .Distinct(ProjectItemComparer.IncludeComparer);

            if (introducedItems.Any())
            {
                var itemGroup = _projectRootElement.AddItemGroup();
                foreach (var introducedItem in introducedItems)
                {
                    var item = itemGroup.AddItem(introducedItem.ItemType, introducedItem.EvaluatedInclude);
                    item.Include = null;
                    item.Remove  = introducedItem.EvaluatedInclude;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Finds the item group where PackageReferences are specified. Usually there is only one.
 /// </summary>
 public static ProjectItemGroupElement GetOrCreatePackageReferencesItemGroup(IProjectRootElement rootElement) =>
 rootElement.ItemGroups.SingleOrDefault(ig => ig.Items.All(i => i.ElementName.Equals(PackageFacts.PackageReferencePackagesNodeName, StringComparison.OrdinalIgnoreCase)))
 ?? rootElement.AddItemGroup();