private static void AddHardcodedPropertyDefault(List <DefaultProjectPropertyInfo> allProperties, string name, string value, string condition = "", string parentCondition = "") { var propertyInfo = new DefaultProjectPropertyInfo { Name = name, Value = value, Condition = condition, ParentCondition = parentCondition }; allProperties.Add(propertyInfo); }
private static void AddConfigurationPropertyDefaults(List <DefaultProjectPropertyInfo> allProperties, ProjectRootElement msbuild, string config) { var configPropertyGroup = msbuild.PropertyGroups.Where(p => p.Condition.Contains("$(Configuration)") && p.Condition.Contains(config)).First(); configPropertyGroup.Condition = $" '$(Configuration)' == '{config}' "; foreach (var property in configPropertyGroup.Properties) { var propertyInfo = new DefaultProjectPropertyInfo { Name = property.Name, Value = property.Value, Condition = property.Condition, ParentCondition = property.Parent.Condition }; allProperties.Add(propertyInfo); } }
private static void AddPropertyDefault(List <DefaultProjectPropertyInfo> allProperties, ProjectRootElement msbuild, string propertyName, int?index = null, bool ignoreConditions = false) { var properties = msbuild.Properties.Where(p => p.Name == propertyName).ToList(); if (!properties.Any()) { throw new Exception("property not found:" + propertyName); } if (properties.Count() > 1 && index == null) { throw new Exception("More than one property found but index is null:" + propertyName); } var property = properties[index ?? 0]; if (ignoreConditions) { var propertyInfo = new DefaultProjectPropertyInfo { Name = property.Name, Value = property.Value, Condition = null, ParentCondition = null }; allProperties.Add(propertyInfo); } else { var propertyInfo = new DefaultProjectPropertyInfo { Name = property.Name, Value = property.Value, Condition = property.Condition, ParentCondition = property.Parent.Condition }; allProperties.Add(propertyInfo); } }