Add missing built-in properties. Resolve properties on import paths. Resolve \ with...
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>
Wed, 13 Nov 2013 10:22:16 +0000 (19:22 +0900)
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>
Tue, 3 Dec 2013 07:50:46 +0000 (16:50 +0900)
mcs/class/Microsoft.Build/Microsoft.Build.Evaluation/Project.cs
mcs/class/Microsoft.Build/Microsoft.Build.Evaluation/ProjectCollection.cs
mcs/class/Microsoft.Build/Microsoft.Build.Internal/WindowsCompatibilityExtensions.cs [new file with mode: 0644]
mcs/class/Microsoft.Build/Microsoft.Build.dll.sources
mcs/class/Microsoft.Build/Test/Microsoft.Build.Evaluation/ProjectTest.cs

index b668eafcee83cea1fca70a0a289538f04b51c601..c7105ba668fe6cce36701b4adc3a31100ddd113f 100644 (file)
@@ -329,17 +329,18 @@ namespace Microsoft.Build.Evaluation
                IEnumerable<ProjectElement> Import (ProjectImportElement import)
                {
                        string dir = ProjectCollection.GetEvaluationTimeThisFileDirectory (() => FullPath);
-                       string path = Path.IsPathRooted (import.Project) ? import.Project : dir != null ? Path.Combine (dir, import.Project) : Path.GetFullPath (import.Project);
+                       string path = ExpandString (import.Project);
+                       path = Path.IsPathRooted (path) ? path : dir != null ? Path.Combine (dir, path) : Path.GetFullPath (path);
                        if (ProjectCollection.OngoingImports.Contains (path)) {
                                switch (load_settings) {
                                case ProjectLoadSettings.RejectCircularImports:
-                                       throw new InvalidProjectFileException (import.Location, null, string.Format ("Circular imports was detected: {0} is already on \"importing\" stack", path));
+                                       throw new InvalidProjectFileException (import.Location, null, string.Format ("Circular imports was detected: {0} (resolved as \"{1}\") is already on \"importing\" stack", import.Project, path));
                                }
                                return new ProjectElement [0]; // do not import circular references
                        }
                        ProjectCollection.OngoingImports.Push (path);
                        try {
-                               using (var reader = XmlReader.Create (path)) {
+                               using (var reader = XmlReader.Create (WindowsCompatibilityExtensions.NormalizeFilePath (path))) {
                                        var root = ProjectRootElement.Create (reader, ProjectCollection);
                                        raw_imports.Add (new ResolvedImport (import, root, true));
                                        return this.EvaluatePropertiesAndImports (root.Children).ToArray ();
index a7f72770440ce84f6e804bec6d8515a8834730d4..fd8ff38e7823b5037bde7bdb7068f883765e7b3d 100644 (file)
@@ -313,6 +313,8 @@ namespace Microsoft.Build.Evaluation
                [MonoTODO]
                public bool IsBuildEnabled { get; set; }
                
+               internal string BuildStartupDirectory { get; set; }
+               
                Stack<string> ongoing_imports = new Stack<string> ();
                
                internal Stack<string> OngoingImports {
@@ -382,12 +384,12 @@ namespace Microsoft.Build.Evaluation
                        // FIXME: add MSBuildProgramFiles32
                        yield return create ("MSBuildProjectDefaultTargets", () => project.DefaultTargets);
                        yield return create ("MSBuildProjectDirectory", () => project.DirectoryPath + Path.DirectorySeparatorChar);
-                       // FIXME: add MSBuildProjectDirectoryNoRoot
+                       yield return create ("MSBuildProjectDirectoryNoRoot", () => project.DirectoryPath.Substring (Path.GetPathRoot (project.DirectoryPath).Length));
                        yield return create ("MSBuildProjectExtension", () => Path.GetExtension (project.FullPath));
                        yield return create ("MSBuildProjectFile", () => Path.GetFileName (project.FullPath));
                        yield return create ("MSBuildProjectFullPath", () => project.FullPath);
                        yield return create ("MSBuildProjectName", () => Path.GetFileNameWithoutExtension (project.FullPath));
-                       // FIXME: add MSBuildStartupDirectory
+                       yield return create ("MSBuildStartupDirectory", () => BuildStartupDirectory);
                        yield return create ("MSBuildThisFile", () => Path.GetFileName (GetEvaluationTimeThisFile (projectFullPath)));
                        yield return create ("MSBuildThisFileFullPath", () => GetEvaluationTimeThisFile (projectFullPath));
                        yield return create ("MSBuildThisFileName", () => Path.GetFileNameWithoutExtension (GetEvaluationTimeThisFile (projectFullPath)));
@@ -398,6 +400,8 @@ namespace Microsoft.Build.Evaluation
                                string dir = GetEvaluationTimeThisFileDirectory (projectFullPath) + Path.DirectorySeparatorChar;
                                return dir.Substring (Path.GetPathRoot (dir).Length);
                                });
+                       yield return create ("MSBuildToolsPath", () => toolset.ToolsPath);
+                       yield return create ("MSBuildToolsVersion", () => toolset.ToolsVersion);
                }
                
                // These are required for reserved property, represents dynamically changing property values.
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Internal/WindowsCompatibilityExtensions.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Internal/WindowsCompatibilityExtensions.cs
new file mode 100644 (file)
index 0000000..f4f9eda
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// WindowsCompatibilityExtensions.cs
+//
+// Author:
+//   Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+
+namespace Microsoft.Build.Internal
+{
+       public static class WindowsCompatibilityExtensions
+       {
+               public static string NormalizeFilePath (string path)
+               {
+                       return path.Replace ('\\', Path.DirectorySeparatorChar);
+               }
+       }
+}
+
index b8a779704ed4f2324f6f9766c37379269ab39fd5..3683fa8a46a9d3d52b80c01602b522d53445f437 100644 (file)
@@ -92,6 +92,7 @@ Microsoft.Build.Internal/ExpressionTokenizer.cs
 Microsoft.Build.Internal/FilteredEnumerable.cs
 Microsoft.Build.Internal/ProjectTaskItem.cs
 Microsoft.Build.Internal/ReverseEnumerable.cs
+Microsoft.Build.Internal/WindowsCompatibilityExtensions.cs
 Microsoft.Build.Logging/ConfigurableForwardingLogger.cs
 Microsoft.Build.Logging/ForwardingLoggerRecord.cs
 Microsoft.Build.Logging/LoggerDescription.cs
index fbace5b9fbe0101e79389dae20f0ab0622426d45..853c55a301e223e4d4205841a89a9b345821141b 100644 (file)
@@ -111,7 +111,6 @@ namespace MonoTests.Microsoft.Build.Evaluation
                }
                
                [Test]
-               [Category ("NotWorking")]
                public void BuildCSharpTargetGetFrameworkPaths ()
                {
             string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>