add some workaround for "PLATFORM" property that should not be filled by environment.
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>
Wed, 27 Nov 2013 10:17:30 +0000 (19:17 +0900)
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>
Fri, 29 Nov 2013 09:23:36 +0000 (18:23 +0900)
Add some tests to evaluate IntermediateOutputPath.

mcs/class/Microsoft.Build/Microsoft.Build.Evaluation/Project.cs
mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectInstance.cs
mcs/class/Microsoft.Build/Test/Microsoft.Build.Evaluation/ProjectPropertyTest.cs
mcs/class/Microsoft.Build/Test/Microsoft.Build.Evaluation/ProjectTest.cs

index b1741a8e521f6e9a35064e1eef98e35774c592fb..a05a903d2fbe2d7da137c126e896187548e80d3a 100644 (file)
@@ -202,7 +202,10 @@ namespace Microsoft.Build.Evaluation
                                properties = new List<ProjectProperty> ();
                        
                                foreach (DictionaryEntry p in Environment.GetEnvironmentVariables ())
-                                       this.properties.Add (new EnvironmentProjectProperty (this, (string)p.Key, (string)p.Value));
+                                       // FIXME: this is kind of workaround for unavoidable issue that PLATFORM=* is actually given
+                                       // on some platforms and that prevents setting default "PLATFORM=AnyCPU" property.
+                                       if (!string.Equals ("PLATFORM", (string) p.Key, StringComparison.OrdinalIgnoreCase))
+                                               this.properties.Add (new EnvironmentProjectProperty (this, (string)p.Key, (string)p.Value));
                                foreach (var p in GlobalProperties)
                                        this.properties.Add (new GlobalProjectProperty (this, p.Key, p.Value));
                                var tools = ProjectCollection.GetToolset (this.ToolsVersion) ?? ProjectCollection.GetToolset (this.ProjectCollection.DefaultToolsVersion);
index d91d3803e84bddf1df81f3a4894f3654d7c8642d..00439c28132b9c9d1f6a4f7877c0bc1ac44c902b 100644 (file)
@@ -139,7 +139,10 @@ namespace Microsoft.Build.Execution
                                properties = new List<ProjectPropertyInstance> ();
                        
                                foreach (DictionaryEntry p in Environment.GetEnvironmentVariables ())
-                                       this.properties.Add (new ProjectPropertyInstance ((string) p.Key, false, (string) p.Value));
+                                       // FIXME: this is kind of workaround for unavoidable issue that PLATFORM=* is actually given
+                                       // on some platforms and that prevents setting default "PLATFORM=AnyCPU" property.
+                                       if (!string.Equals ("PLATFORM", (string) p.Key, StringComparison.OrdinalIgnoreCase))
+                                               this.properties.Add (new ProjectPropertyInstance ((string) p.Key, false, (string) p.Value));
                                foreach (var p in global_properties)
                                        this.properties.Add (new ProjectPropertyInstance (p.Key, false, p.Value));
                                var tools = projects.GetToolset (tools_version) ?? projects.GetToolset (projects.DefaultToolsVersion);
index f94aef904ca2b54e382ebc3ae8a0d0dac1c706d2..9c89ef09f6bc98844f82c39575ada0ea11cd7633 100644 (file)
@@ -115,6 +115,16 @@ namespace MonoTests.Microsoft.Build.Evaluation
                        Assert.AreEqual ("1+1+2", new Project (root).GetProperty ("C").EvaluatedValue, "#1");
                        Assert.AreEqual ("1+1+2", new ProjectInstance (root).GetProperty ("C").EvaluatedValue, "#1");
                }
+               
+               [Test]
+               public void PlatformPropertyEmptyByDefault ()
+               {
+                       string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' />";
+                       var xml = XmlReader.Create (new StringReader (project_xml));
+                       var root = ProjectRootElement.Create (xml);
+                       var proj = new Project (root);
+                       Assert.IsNull (proj.GetProperty ("PLATFORM"), "#1");
+               }
        }
 }
 
index 0461e4ac192283d7fd53166ff1d75d3133a3ab51..439ad4b0c27d0beabacb0bcd66fbd194202c010b 100644 (file)
@@ -186,6 +186,21 @@ namespace MonoTests.Microsoft.Build.Evaluation
                        Assert.IsNotNull ("Baz", proj.ItemsIgnoringCondition.Last ().ItemType, "#3");
                }
                
+               [Test]
+               public void EvaluateSamePropertiesInOrder ()
+               {
+                       // used in Microsoft.Common.targets
+            string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+  <PropertyGroup>
+    <BaseIntermediateOutputPath Condition=""'$(BaseIntermediateOutputPath)' == ''"">obj\</BaseIntermediateOutputPath>
+  </PropertyGroup>
+</Project>";
+                       var xml = XmlReader.Create (new StringReader (project_xml));
+                       var root = ProjectRootElement.Create (xml);
+                       var proj = new Project (root);
+                       Assert.AreEqual ("obj\\", proj.GetPropertyValue ("BaseIntermediateOutputPath"), "#1");
+               }
+               
                [Test]
                public void DirtyMarking ()
                {