Пример #1
0
        private ProjectPropertyGroupElement GetOrCreateEmptyPropertyGroup()
        {
            bool IsAfterFirstImport(ProjectPropertyGroupElement propertyGroup)
            {
                if (_sdkBaselineProject.ProjectStyle == ProjectStyle.Default)
                {
                    return(true);
                }

                var firstImport = _projectRootElement.Imports.Where(i => i.Label != Facts.SharedProjectsImportLabel).First();

                return(propertyGroup.Location.Line > firstImport.Location.Line);
            }

            return(_projectRootElement.PropertyGroups.FirstOrDefault(pg => pg.Condition == "" &&
                                                                     IsAfterFirstImport(pg))
                   ?? _projectRootElement.AddPropertyGroup());
        }
Пример #2
0
 /// <summary>
 /// Finds the property group with the TFM specified, which is normally the top-level property group.
 /// </summary>
 public static ProjectPropertyGroupElement GetOrCreateTopLevelPropertyGroupWithTFM(IProjectRootElement rootElement) =>
 rootElement.PropertyGroups.Single(pg => pg.Properties.Any(p => p.ElementName.Equals(MSBuildFacts.TargetFrameworkNodeName, StringComparison.OrdinalIgnoreCase)))
 ?? rootElement.AddPropertyGroup();