static void GetPropertiesToTrack(PropertyValueCollector propertyVals, MSBuildProjectElement project) { foreach (var el in project.Elements) { if (el is MSBuildImportElement imp) { var impAtt = imp.ProjectAttribute?.Value; if (impAtt != null) { MarkProperties(impAtt); } } else if (el is MSBuildUsingTaskElement ut) { var afAtt = ut.AssemblyFileAttribute?.Value; if (afAtt != null) { MarkProperties(afAtt); } } } void MarkProperties(ExpressionNode expr) { foreach (var prop in expr.WithAllDescendants().OfType <ExpressionProperty> ()) { propertyVals.Mark(prop.Name); } } }
static void GetPropertiesToTrack(PropertyValueCollector propertyVals, XElement project) { foreach (var el in project.Elements) { if (el.NameEquals("Import", true)) { var impAtt = el.Attributes.Get(new XName("Project"), true); if (impAtt != null) { MarkProperties(impAtt); } } else if (el.NameEquals("UsingTask", true)) { var afAtt = el.Attributes.Get(new XName("AssemblyFile"), true); if (afAtt != null) { MarkProperties(afAtt); } } } void MarkProperties(XAttribute att) { var expr = ExpressionParser.Parse(att.Value, ExpressionOptions.None); foreach (var prop in expr.WithAllDescendants().OfType <ExpressionProperty> ()) { propertyVals.Mark(prop.Name); } } }