public static void CopyPropertyIfExists(ITaskItem item, IDictionary <string, string> properties, string key, string toKey) { var wrapper = new MSBuildTaskItem(item); var propertyValue = wrapper.GetProperty(key); if (!string.IsNullOrEmpty(propertyValue) && !properties.ContainsKey(key)) { properties.Add(toKey, propertyValue); } }
public static string GetPropertyIfExists(ITaskItem item, string key) { var wrapper = new MSBuildTaskItem(item); var propertyValue = wrapper.GetProperty(key); if (!string.IsNullOrEmpty(propertyValue)) { return(propertyValue); } return(null); }