+2010-01-21 Rodrigo B. de Oliveira <rodrigo@unity3d.com>
+
+ * Microsoft.Build.BuildEngine/BuildWhen.cs
+ * Microsoft.Build.BuildEngine/PropertyReference.cs:
+ support for nested Choose elements + fixed bug where the project reference
+ would be null during condition evaluation.
+
2010-01-12 Rodrigo B. de Oliveira <rodrigo@unity3d.com>
* Microsoft.Build.BuildEngine/BuildWhen.cs
public BuildWhen (XmlElement whenElement, Project parentProject)
{
-
this.parentProject = parentProject;
- this.groupingCollection = new GroupingCollection (null);
+ this.groupingCollection = new GroupingCollection (parentProject);
if (whenElement == null)
throw new ArgumentNullException ("whenElement");
this.whenElement = whenElement;
foreach (XmlElement xe in whenElement.ChildNodes) {
- if (xe.Name == "ItemGroup") {
- BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
- //big.BindToXml (xe);
- groupingCollection.Add (big);
- // FIXME: add nested chooses
- } else if (xe.Name == "PropertyGroup") {
- BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
- //bpg.BindToXml (xe);
- groupingCollection.Add (bpg);
- } else
- throw new InvalidProjectFileException ("Invalid element in When.");
+ switch (xe.Name) {
+ case "ItemGroup":
+ BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
+ //big.BindToXml (xe);
+ groupingCollection.Add (big);
+ break;
+ case "PropertyGroup":
+ BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
+ //bpg.BindToXml (xe);
+ groupingCollection.Add (bpg);
+ break;
+ case "Choose":
+ BuildChoose bc = new BuildChoose (xe, parentProject);
+ groupingCollection.Add (bc);
+ break;
+ default:
+ throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
+ }
}
-
}
public void Evaluate()
// so, always true, ignore @options
public string ConvertToString (Project project, ExpressionOptions options)
{
+ if (project == null)
+ throw new ArgumentNullException ("project");
+
BuildProperty bp = project.EvaluatedProperties [name];
if (bp == null)
return String.Empty;
Assert.AreEqual ("Baz", project.GetEvaluatedProperty ("Foo"), "A1");
}
+
+ [Test]
+ public void NestedChooseInOtherwise () {
+
+ string documentString = @"
+ <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <Choose>
+ <When Condition=""'$(Configuration)' == 'dummy'"">
+ <PropertyGroup>
+ <Foo>Bar</Foo>
+ </PropertyGroup>
+ </When>
+ <Otherwise>
+ <Choose>
+ <When Condition="" 'foo' == 'bar' "">
+ <PropertyGroup>
+ <Foo>Baz</Foo>
+ </PropertyGroup>
+ </When>
+ <Otherwise>
+ <PropertyGroup>
+ <Foo>Baz</Foo>
+ </PropertyGroup>
+ </Otherwise>
+ </Choose>
+ </Otherwise>
+ </Choose>
+ </Project>
+ ";
+
+ Engine engine = new Engine (Consts.BinPath);
+ Project project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ Assert.AreEqual ("Baz", project.GetEvaluatedProperty ("Foo"), "A1");
+ }
+
+
+ [Test]
+ public void UndefinedPropertyInExistsCondition()
+ {
+ string documentString = @"
+ <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <PropertyGroup>
+ <Foo>Bar</Foo>
+ </PropertyGroup>
+ <Choose>
+ <When Condition = "" '$(teamcity_dotnet_nunitlauncher_msbuild_task)' == '' "" >
+ <Choose>
+ <When Condition=""Exists('$(UndefinedProperty)\Foo\Bar')"">
+ <PropertyGroup>
+ <Exists>yes</Exists>
+ </PropertyGroup>
+ </When>
+ <Otherwise>
+ <PropertyGroup>
+ <Exists>no</Exists>
+ </PropertyGroup>
+ </Otherwise>
+ </Choose>
+ </When>
+ </Choose>
+ </Project>
+ ";
+
+ Engine engine = new Engine (Consts.BinPath);
+ Project project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ Assert.AreEqual ("no", project.GetEvaluatedProperty ("Exists"), "A1");
+ }
}
}
}
[Test]
- public void TestValueXml ()
- {
- BuildPropertyGroup [] bpgs = new BuildPropertyGroup [1];
- BuildProperty [] props;
- XmlDocument xd;
- XmlNode node;
+ public void TestValueXml ()
+ {
+ BuildPropertyGroup [] bpgs = new BuildPropertyGroup [1];
+ BuildProperty [] props;
+ XmlDocument xd;
+ XmlNode node;
- string documentString = @"
- <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <PropertyGroup>
- <Name>Value</Name>
- </PropertyGroup>
- </Project>
- ";
+ string documentString = @"
+ <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+ <PropertyGroup>
+ <Name>Value</Name>
+ </PropertyGroup>
+ </Project>
+ ";
- engine = new Engine (Consts.BinPath);
+ engine = new Engine (Consts.BinPath);
- project = engine.CreateNewProject ();
- project.LoadXml (documentString);
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
- project.PropertyGroups.CopyTo (bpgs, 0);
- bpgs[0].AddNewProperty("XmlProp", "<XmlStuff></XmlStuff>");
+ project.PropertyGroups.CopyTo (bpgs, 0);
+ bpgs[0].AddNewProperty("XmlProp", "<XmlStuff></XmlStuff>");
- xd = new XmlDocument ();
- xd.LoadXml (project.Xml);
+ xd = new XmlDocument ();
+ xd.LoadXml (project.Xml);
Console.WriteLine(project.Xml);
- node = xd.SelectSingleNode ("tns:Project/tns:PropertyGroup/tns:XmlProp/tns:XmlStuff", TestNamespaceManager.NamespaceManager);
- Assert.IsNotNull (node, "A1");
- }
+ node = xd.SelectSingleNode ("tns:Project/tns:PropertyGroup/tns:XmlProp/tns:XmlStuff", TestNamespaceManager.NamespaceManager);
+ Assert.IsNotNull (node, "A1");
+ }
}
}
+2010-01-21 Rodrigo B. de Oliveira <rodrigo@unity3d.com>
+
+ * BuildChooseTest.cs
+ * BuildPropertyTest.cs:
+ test cases for nested Choose elements and different property
+ evaluation scenarios.
+
2009-10-08 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestBatchedMetadataRefInOutput): New.