protected virtual ProjectPropertyGroupElement ClonePropertyGroup(MSBuild.Project project, ProjectPropertyGroupElement group)
{
if (project == null)
throw new ArgumentNullException("project");
if (group == null)
throw new ArgumentNullException("group");
// Create a new (empty) PropertyGroup
ProjectPropertyGroupElement newPropertyGroup = project.Xml.CreatePropertyGroupElement();
project.Xml.InsertAfterChild(newPropertyGroup, group);
// Now copy everything from the group we are trying to clone to the group we are creating
if (!String.IsNullOrEmpty(group.Condition))
newPropertyGroup.Condition = group.Condition;
foreach (ProjectPropertyElement prop in group.Properties)
{
ProjectPropertyElement newProperty = newPropertyGroup.AddProperty(prop.Name, prop.Value);
if (!String.IsNullOrEmpty(prop.Condition))
newProperty.Condition = prop.Condition;
}
return newPropertyGroup;
}