using System;
using System.Text;
using System.Xml;
+using System.Collections.Generic;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
internal XmlElement XmlElement {
get { return propertyElement; }
}
+
+ internal IEnumerable<string> GetAttributes ()
+ {
+ if (!FromXml)
+ yield break;
+ foreach (XmlAttribute attr in propertyElement.Attributes)
+ yield return attr.Value;
+ }
}
internal enum PropertyType {
List <BuildProperty> properties;
Dictionary <string, BuildProperty> propertiesByName;
bool evaluated;
+ bool isDynamic;
public BuildPropertyGroup ()
: this (null, null, null, false)
}
internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly)
+ : this (xmlElement, project, importedProject, readOnly, false)
+ {
+ }
+
+ internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool isDynamic)
{
this.importedProject = importedProject;
this.parentCollection = null;
this.parentProject = project;
this.propertyGroup = xmlElement;
this.read_only = readOnly;
+ this.isDynamic = isDynamic;
if (FromXml) {
this.properties = new List <BuildProperty> ();
internal void Evaluate ()
{
- if (evaluated)
+ if (!isDynamic && evaluated)
return;
foreach (BuildProperty bp in properties)
internal XmlElement XmlElement {
get { return propertyGroup; }
}
+
+ internal IEnumerable<string> GetAttributes ()
+ {
+ foreach (XmlAttribute attrib in XmlElement.Attributes)
+ yield return attrib.Value;
+
+ foreach (BuildProperty bp in properties) {
+ foreach (string attr in bp.GetAttributes ())
+ yield return attr;
+ }
+ }
}
}
}
internal BuildTaskPropertyGroup (XmlElement element, Target target)
- : base (element, target.Project, null, false)
+ : base (element, target.Project, null, false, true)
{
}
return true;
}
- public IEnumerable<string> GetAttributes ()
+ IEnumerable<string> IBuildTask.GetAttributes ()
{
- foreach (XmlAttribute attrib in XmlElement.Attributes)
- yield return attrib.Value;
+ return GetAttributes ();
}
}
</Target>
</Project>", "Sun", "Rain");
}
+
+ [Test]
+ public void PropertyGroupInsideTarget_Condition ()
+ {
+ ItemGroupInsideTarget (
+ @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
+ <ItemGroup>
+ <Shells Include=""/bin/sh;/bin/bash;/bin/false"" />
+ </ItemGroup>
+
+ <Target Name='Main'>
+ <PropertyGroup>
+ <HasBash Condition=""'%(Shells.Filename)' == 'bash'"">true</HasBash>
+ </PropertyGroup>
+
+ <ItemGroup Condition=""'$(HasBash)' == 'true'"">
+ <Weather Include='Rain' />
+ </ItemGroup>
+ <Message Text='%(Weather.Identity)' />
+ </Target>
+ </Project>", "Rain");
+ }
#endif
[Test]