- if (propertiesByName.Contains (propertyName) == false) {
- AddNewProperty (propertyName, propertyValue);
- }
- ((BuildProperty) propertiesByName [propertyName]).Value = propertyValue;
+ if (read_only)
+ return;
+ if (FromXml)
+ throw new InvalidOperationException (
+ "This method is only valid for virtual property groups, not <PropertyGroup> elements.");
+
+ if (treatPropertyValueAsLiteral)
+ propertyValue = Utilities.Escape (propertyValue);
+
+ if (propertiesByName.ContainsKey (propertyName))
+ propertiesByName.Remove (propertyName);
+
+ BuildProperty bp = new BuildProperty (propertyName, propertyValue);
+ if (Char.IsDigit (propertyName [0]))
+ throw new ArgumentException (String.Format (
+ "The name \"{0}\" contains an invalid character \"{1}\".", propertyName, propertyName [0]));
+
+ AddProperty (bp);
+
+ if (IsGlobal)
+ parentProject.NeedToReevaluate ();