Skip to content
Browse files

Fix SD-1718 - Post build events not added to end of project file.

  • Loading branch information...
1 parent 42ebc0b commit e1cc2ab2e4e25a2e4821919a671eee2f31d76326 @mrward mrward committed Nov 16, 2010
Showing with 38 additions and 6 deletions.
  1. +38 −6 src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
View
44 src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
@@ -839,18 +839,50 @@ enum PropertyPosition
}
}
}
- foreach (var propertyGroup in targetProject.PropertyGroups) {
- if (propertyGroup.Condition == groupCondition) {
- propertyGroup.AddProperty(propertyName, newValue);
- return;
- }
+
+ var matchedPropertyGroup = FindPropertyGroup(targetProject, groupCondition, position);
+ if (matchedPropertyGroup != null) {
+ matchedPropertyGroup.AddProperty(propertyName, newValue);
+ return;
}
- var newGroup = targetProject.AddPropertyGroup();
+ var newGroup = AddNewPropertyGroup(targetProject, position);
newGroup.Condition = groupCondition;
newGroup.AddProperty(propertyName, newValue);
}
+ ProjectPropertyGroupElement FindPropertyGroup(ProjectRootElement targetProject, string groupCondition, PropertyPosition position)
+ {
+ ProjectPropertyGroupElement matchedPropertyGroup = null;
+ foreach (var projectItem in targetProject.Children) {
+ ProjectPropertyGroupElement propertyGroup = projectItem as ProjectPropertyGroupElement;
+ if (propertyGroup != null) {
+ if (propertyGroup.Condition == groupCondition) {
+ matchedPropertyGroup = propertyGroup;
+ if (position != PropertyPosition.UseExistingOrCreateAfterLastImport) {
+ return matchedPropertyGroup;
+ }
+ }
+ }
+ if (position == PropertyPosition.UseExistingOrCreateAfterLastImport) {
+ if (projectItem is ProjectImportElement) {
+ matchedPropertyGroup = null;
+ }
+ }
+ }
+ return matchedPropertyGroup;
+ }
+
+ ProjectPropertyGroupElement AddNewPropertyGroup(ProjectRootElement targetProject, PropertyPosition position)
+ {
+ if (position == PropertyPosition.UseExistingOrCreateAfterLastImport) {
+ var propertyGroup = targetProject.CreatePropertyGroupElement();
+ targetProject.AppendChild(propertyGroup);
+ return propertyGroup;
+ }
+ return targetProject.AddPropertyGroup();
+ }
+
/// <summary>
/// Removes the property from all configurations and platforms.
/// </summary>

0 comments on commit e1cc2ab

Please sign in to comment.
Something went wrong with that request. Please try again.