Permalink
Browse files

Merge pull request #462 from knocte/master

Changes to make F# build out of the box with xbuild
  • Loading branch information...
2 parents 142e70f + 8ed93b1 commit cca3cb128fc4f191fe9d93664dfedd90fe3bd763 @marek-safar marek-safar committed Sep 17, 2012
@@ -75,6 +75,13 @@ internal Target (XmlElement targetElement, Project project, ImportedProject impo
} else if (onErrorFound)
throw new InvalidProjectFileException (
"The element <OnError> must be last under element <Target>. Found element <Error> instead.");
+#if NET_3_5
+ else if (xe.Name == "ItemGroup") {
+ //don't blow up for ItemGroups inside Targets in >= 3.5
+ // TODO: evaluate them (see https://bugzilla.xamarin.com/show_bug.cgi?id=1862 and test in TargetTest.cs )
+ continue;
+ }
+#endif
else
buildTasks.Add (new BuildTask (xe, this));
}
@@ -348,6 +348,79 @@ public void TestTargetOutputs1 ()
}
}
+#if NET_3_5
+ [Test]
+ public void BuildProjectWithItemGroupInsideTarget()
+ {
+ ItemGroupInsideATarget ();
+ }
+
+ private MonoTests.Microsoft.Build.Tasks.TestMessageLogger ItemGroupInsideATarget() {
+ var engine = new Engine(Consts.BinPath);
+ var project = engine.CreateNewProject();
+ var projectXml = GetProjectXmlWithItemGroupInsideATarget ();
+ project.LoadXml(projectXml);
+
+ MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
+ new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
+ engine.RegisterLogger (logger);
+
+ bool result = project.Build("Main");
+ if (!result)
+ {
+ logger.DumpMessages ();
+ Assert.Fail("Build failed");
+ }
+
+ return logger;
+ }
+
+ private string GetProjectXmlWithItemGroupInsideATarget ()
+ {
+ return
+ @"<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+ <ItemGroup>
+ <fruit Include=""apple""/>
+ <fruit Include=""apricot""/>
+ </ItemGroup>
+
+ <Target Name=""Main"">
+ <ItemGroup>
+ <fruit Include=""raspberry"" />
+ </ItemGroup>
+ <Message Text=""%(fruit.Identity)""/>
+ </Target>
+ </Project>";
+ }
+
+ [Test]
+ [Category ("NotWorking")] //https://bugzilla.xamarin.com/show_bug.cgi?id=1862
+ public void BuildProjectOutputWithItemGroupInsideTarget()
+ {
+ var logger = ItemGroupInsideATarget ();
+
+ try
+ {
+ Assert.AreEqual(3, logger.NormalMessageCount, "Expected number of messages");
+ logger.CheckLoggedMessageHead("apple", "A1");
+ logger.CheckLoggedMessageHead("apricot", "A2");
+ logger.CheckLoggedMessageHead("raspberry", "A3");
+ Assert.AreEqual(0, logger.NormalMessageCount, "Extra messages found");
+
+ Assert.AreEqual(1, logger.TargetStarted, "TargetStarted count");
+ Assert.AreEqual(1, logger.TargetFinished, "TargetFinished count");
+ Assert.AreEqual(3, logger.TaskStarted, "TaskStarted count");
+ Assert.AreEqual(3, logger.TaskFinished, "TaskFinished count");
+
+ }
+ catch (AssertionException)
+ {
+ logger.DumpMessages();
+ throw;
+ }
+ }
+#endif
+
[Test]
public void TestTargetOutputsIncludingMetadata ()
{
@@ -268,14 +268,11 @@
</Copy>
</Target>
-<!--
- Not needed at the moment
<Target Name="_ComputeNonExistentFileProperty" Condition='false'>
<CreateProperty Value="__NonExistentSubDir__\__NonExistentFile__">
<Output TaskParameter="Value" PropertyName="NonExistentFile"/>
</CreateProperty>
</Target>
--->
<PropertyGroup>
<BuildDependsOn>
@@ -315,14 +315,11 @@
</Copy>
</Target>
-<!--
- Not needed at the moment
<Target Name="_ComputeNonExistentFileProperty" Condition='false'>
<CreateProperty Value="__NonExistentSubDir__\__NonExistentFile__">
<Output TaskParameter="Value" PropertyName="NonExistentFile"/>
</CreateProperty>
</Target>
--->
<PropertyGroup>
<BuildDependsOn>
@@ -318,14 +318,11 @@
</Copy>
</Target>
-<!--
- Not needed at the moment
<Target Name="_ComputeNonExistentFileProperty" Condition='false'>
<CreateProperty Value="__NonExistentSubDir__\__NonExistentFile__">
<Output TaskParameter="Value" PropertyName="NonExistentFile"/>
</CreateProperty>
</Target>
--->
<PropertyGroup>
<BuildDependsOn>

0 comments on commit cca3cb1

Please sign in to comment.