internal static void AddItemToGroup(MSBuild.BuildItemGroup group, ProjectItem item) { if (group == null) throw new ArgumentNullException("group"); if (item == null) throw new ArgumentNullException("item"); if (item.IsAddedToProject) throw new ArgumentException("item is already added to project", "item"); MSBuild.BuildItem newItem = group.AddNewItem(item.ItemType.ToString(), item.Include, true); foreach (string name in item.MetadataNames) { newItem.SetMetadata(name, item.GetMetadata(name)); } item.BuildItem = newItem; Debug.Assert(item.IsAddedToProject); }