[mono/mono] [11 commits] b9a4200c: [xBuild] Support ToolsVersion 12

"Atsushi Eno ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141ca939ac5-41ce39f0-2e69-4e4f-9c73-9bb69b1e517c-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/6934f160db0e...0075f3921505

   Commit: b9a4200cae4334ccefe0ca6e41bbf08e79c096ad
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-09-29 20:13:58 GMT
      URL: https://github.com/mono/mono/commit/b9a4200cae4334ccefe0ca6e41bbf08e79c096ad

[xBuild] Support ToolsVersion 12

From VS2013, MSBuild is now decouple from the .NET Framework and is a separate redistributable. This means it has a new location and version numbering scheme. There are also some addition MSBuild properties because of this

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
  M mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
===================================================================
@@ -118,6 +118,11 @@ void LoadDefaultToolsets ()
 			Toolsets.Add (new Toolset ("4.0",
 						ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
 #endif
+#if NET_4_5
+			Toolsets.Add (new Toolset("12.0",
+						ToolLocationHelper.GetMSBuildInstallPath ("12.0"),
+						ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
+#endif
 		}
 		
 		[MonoTODO]

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
@@ -1029,7 +1029,17 @@ void InitializeProperties (string effective_tools_version)
 			SetExtensionsPathProperties (DefaultExtensionsPath);
 			evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
 			evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
-
+#if NET_4_5	
+			// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
+			if (effective_tools_version == "12.0") {
+				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));
+				string frameworkToolsPath = parentEngine.Toolsets [effective_tools_version].FrameworkToolsPath;
+				if (frameworkToolsPath == null)
+					throw new Exception (String.Format ("Invalid tools version '{0}', no framework tools path set for this.", effective_tools_version));				
+				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildFrameworkToolsPath", frameworkToolsPath, PropertyType.Reserved));
+				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildFrameworkToolsPath32", frameworkToolsPath, PropertyType.Reserved));
+			}
+#endif
 			// FIXME: make some internal method that will work like GetDirectoryName but output String.Empty on null/String.Empty
 			string projectDir;
 			if (FullFileName == String.Empty)

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
===================================================================
@@ -31,15 +31,21 @@ namespace Microsoft.Build.BuildEngine
 {
 	public class Toolset
 	{
-		public Toolset (string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
+		public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath, BuildPropertyGroup buildProperties)
 		{
 			ToolsVersion = toolsVersion;
 			ToolsPath = toolsPath;
+			FrameworkToolsPath = toolsFrameworkPath;
 			BuildProperties = buildProperties;
 		}
-		
-		public Toolset (string toolsVersion, string toolsPath)
-			: this (toolsVersion, toolsPath, null)
+
+		public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath)
+			: this (toolsVersion, toolsPath, toolsFrameworkPath, null)
+		{
+		}
+
+		public Toolset(string toolsVersion, string toolsPath)
+			: this (toolsVersion, toolsPath, toolsPath)
 		{
 		}
 
@@ -47,5 +53,6 @@ public Toolset (string toolsVersion, string toolsPath)
 
 		public string ToolsVersion { get; private set; }
 		public string ToolsPath { get; private set; }
+		public string FrameworkToolsPath { get; private set; }		
 	}
 }

Modified: mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
===================================================================
@@ -48,6 +48,7 @@ static ToolLocationHelper ()
 			t2 = t1.Parent;
 
 			lib_mono_dir = t2.FullName;
+			var windowsPath = Environment.GetFolderPath (Environment.SpecialFolder.Windows);
 			if (Environment.GetEnvironmentVariable ("TESTING_MONO") != null) {
 				mono_dir = new string [] {
 					Path.Combine (lib_mono_dir, "net_1_0"),
@@ -57,6 +58,16 @@ static ToolLocationHelper ()
 					Path.Combine (lib_mono_dir, "net_4_0"),
 					Path.Combine (lib_mono_dir, "net_4_5")
 				};	
+			} else if (!string.IsNullOrEmpty (windowsPath) && lib_mono_dir.StartsWith (windowsPath)) {
+				//running in .NET, not Mono
+				mono_dir = new string [] {
+					Path.Combine (lib_mono_dir, "v1.0.3705"),
+					Path.Combine (lib_mono_dir, "v2.0.50727"),
+					Path.Combine (lib_mono_dir, "v2.0.50727"),
+					Path.Combine (lib_mono_dir, "v3.5"),
+					Path.Combine (lib_mono_dir, "v4.0.30319"),
+					Path.Combine (lib_mono_dir, "v4.0.30319")
+				};
 			} else {
 				mono_dir = new string [] {
 					Path.Combine (lib_mono_dir, "1.0"),
@@ -93,6 +104,13 @@ public static string GetPathToDotNetFramework (TargetDotNetFrameworkVersion vers
 			return mono_dir [(int)version];
 		}
 
+		public static string GetMSBuildInstallPath (string version)
+		{
+			//see http://msdn.microsoft.com/en-us/library/vstudio/bb397428(v=vs.120).aspx
+			var programFiles = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
+			return Path.Combine (programFiles, "MSBuild", version, "bin");
+		}
+
 		[MonoTODO]
 		public static string GetPathToDotNetFrameworkFile (string fileName,
 								  TargetDotNetFrameworkVersion version)

   Commit: fed01f9b44afd202e40e828e2345f43e11b5f655
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-09-29 20:21:34 GMT
      URL: https://github.com/mono/mono/commit/fed01f9b44afd202e40e828e2345f43e11b5f655

[xBuild] Support use of properties defined in Choose elements in project references

This is used by the .fsproj files generated by VS2013 which use a Choose element to set the location of the F# targets file to import

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
@@ -1114,9 +1114,10 @@ void AddUsingTask (XmlElement xmlElement, ImportedProject importedProject)
 		void AddImport (XmlElement xmlElement, ImportedProject importingProject, bool evaluate_properties)
 		{
 			// eval all the properties etc till the import
-			if (evaluate_properties)
+			if (evaluate_properties) {
 				groupingCollection.Evaluate (EvaluationType.Property);
-
+				groupingCollection.Evaluate (EvaluationType.Choose);
+			}
 			try {
 				PushThisFileProperty (importingProject != null ? importingProject.FullFileName : FullFileName);
 

   Commit: ad8b4d7a4b02d7662e664dd7263833f600fdd8fe
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-09-29 20:22:47 GMT
      URL: https://github.com/mono/mono/commit/ad8b4d7a4b02d7662e664dd7263833f600fdd8fe

[xBuild] Suport >= in string conditions

e.g: '$(MSBuildAssemblyVersion)' == '' and ('$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' >= '12.0'), used in the .targets files shipped with VS2013

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionFactorExpresion.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionFactorExpresion.cs
===================================================================
@@ -109,6 +109,11 @@ public override bool CanEvaluateToNumber (Project context)
 		{
 			if (token.Type == TokenType.Number)
 				return true;
+			else if (token.Type == TokenType.String) {
+				var text = StringEvaluate (context);
+				Single number;
+				return Single.TryParse (text, out number);
+			}
 			else
 				return false;
 		}

   Commit: 29bb48cdc733b03b3b055dafd9bb149657e17192
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-09-29 20:26:00 GMT
      URL: https://github.com/mono/mono/commit/29bb48cdc733b03b3b055dafd9bb149657e17192

[xBuild] Support for ImportGroup element

Used in the .targets files shipped with VS2013

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
@@ -937,6 +937,9 @@ internal void ProcessElements (XmlElement rootElement, ImportedProject ip)
 					case "Import":
 						AddImport (xe, ip, true);
 						break;
+					case "ImportGroup":
+						AddImportGroup (xe, ip, true);
+						break;
 					case "ItemGroup":
 						AddItemGroup (xe, ip);
 						break;
@@ -947,7 +950,7 @@ internal void ProcessElements (XmlElement rootElement, ImportedProject ip)
 						AddChoose (xe, ip);
 						break;
 					default:
-						throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file.", xe.Name));
+						throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file '{1}'.", xe.Name, ip.FullFileName));
 					}
 				}
 			}
@@ -1132,6 +1135,30 @@ void AddImport (XmlElement xmlElement, ImportedProject importingProject, bool ev
 			}
 		}
 
+		void AddImportGroup (XmlElement xmlElement, ImportedProject importedProject, bool evaluate_properties)
+		{
+			// eval all the properties etc till the import group
+			if (evaluate_properties) {
+				groupingCollection.Evaluate (EvaluationType.Property);
+				groupingCollection.Evaluate (EvaluationType.Choose);
+			}
+			string condition_attribute = xmlElement.GetAttribute ("Condition");
+			if (!ConditionParser.ParseAndEvaluate (condition_attribute, this))
+				return;
+			foreach (XmlNode xn in xmlElement.ChildNodes) {
+				if (xn is XmlElement) {
+					XmlElement xe = (XmlElement) xn;
+					switch (xe.Name) {
+					case "Import":
+						AddImport (xe, importedProject, evaluate_properties);
+						break;
+					default:
+						throw new InvalidProjectFileException(String.Format("Invalid element '{0}' inside ImportGroup in project file '{1}'.", xe.Name, importedProject.FullFileName));
+					}
+				}
+			}
+		}
+
 		bool AddSingleImport (XmlElement xmlElement, string projectPath, ImportedProject importingProject, string from_source_msg)
 		{
 			Import import = new Import (xmlElement, projectPath, this, importingProject);

   Commit: f7a787b140751c2650319d63bf06fb7ca1a769a8
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-09-29 20:28:56 GMT
      URL: https://github.com/mono/mono/commit/f7a787b140751c2650319d63bf06fb7ca1a769a8

[xBuild] Fix Import elements with the combination of wildcards and absolute paths

Used in the .targets files shipped with VS2013

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs
===================================================================
@@ -96,14 +96,17 @@ public void Scan ()
 					return;
 
 				int offset = 0;
+				string full_path;
 				if (Path.IsPathRooted (name)) {
+					full_path = name;
 					baseDirectory = new DirectoryInfo (Path.GetPathRoot (name));
 					if (IsRunningOnWindows)
 						// skip the "drive:"
 						offset = 1;
+				} else {
+					full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, name));
 				}
 
-				string full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, include_item.ItemSpec));
 				fileInfo = ParseIncludeExclude (separatedPath, offset, baseDirectory);
 
 				int wildcard_offset = full_path.IndexOf ("**");

   Commit: 80dea22861a05291ead474944f27ab92f54cbdf2
   Author: Robin Neatherway <[email protected]> (rneatherway)
Committer: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-10-01 20:45:13 GMT
      URL: https://github.com/mono/mono/commit/80dea22861a05291ead474944f27ab92f54cbdf2

[xBuild] Fix compilation for Mono 2.0

Changed paths:
  M mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs

Modified: mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
===================================================================
@@ -48,7 +48,9 @@ static ToolLocationHelper ()
 			t2 = t1.Parent;
 
 			lib_mono_dir = t2.FullName;
+#if NET_3_0
 			var windowsPath = Environment.GetFolderPath (Environment.SpecialFolder.Windows);
+#endif
 			if (Environment.GetEnvironmentVariable ("TESTING_MONO") != null) {
 				mono_dir = new string [] {
 					Path.Combine (lib_mono_dir, "net_1_0"),
@@ -58,6 +60,7 @@ static ToolLocationHelper ()
 					Path.Combine (lib_mono_dir, "net_4_0"),
 					Path.Combine (lib_mono_dir, "net_4_5")
 				};	
+#if NET_3_0
 			} else if (!string.IsNullOrEmpty (windowsPath) && lib_mono_dir.StartsWith (windowsPath)) {
 				//running in .NET, not Mono
 				mono_dir = new string [] {
@@ -68,6 +71,7 @@ static ToolLocationHelper ()
 					Path.Combine (lib_mono_dir, "v4.0.30319"),
 					Path.Combine (lib_mono_dir, "v4.0.30319")
 				};
+#endif
 			} else {
 				mono_dir = new string [] {
 					Path.Combine (lib_mono_dir, "1.0"),
@@ -104,12 +108,14 @@ public static string GetPathToDotNetFramework (TargetDotNetFrameworkVersion vers
 			return mono_dir [(int)version];
 		}
 
+#if NET_3_0
 		public static string GetMSBuildInstallPath (string version)
 		{
 			//see http://msdn.microsoft.com/en-us/library/vstudio/bb397428(v=vs.120).aspx
 			var programFiles = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
 			return Path.Combine (programFiles, "MSBuild", version, "bin");
 		}
+#endif
 
 		[MonoTODO]
 		public static string GetPathToDotNetFrameworkFile (string fileName,

   Commit: 92eda1e2a6e5b4cbaecdfe1aa739b12bd328e9f1
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-10-01 20:45:54 GMT
      URL: https://github.com/mono/mono/commit/92eda1e2a6e5b4cbaecdfe1aa739b12bd328e9f1

[xBuild] Fix use of properties in project references when those properties use MSBuildExtensionPath after expanded

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
===================================================================
@@ -159,12 +159,23 @@ string GetFullPath ()
 			else
 				base_dir_info = new DirectoryInfo (Directory.GetCurrentDirectory ());
 
-			IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
+			var importPaths = GetImportPathsFromString (project_attribute, project, base_dir_info);
+			var extensionPaths = GetExtensionPaths (project);
+
+			if (!has_extn_ref) {
+				foreach (var importPath in importPaths) {
+					foreach (var extensionPath in extensionPaths) {
+						has_extn_ref = has_extn_ref || importPath.IndexOf (extensionPath) >= 0;
+					}
+				}
+			}
+
+			IEnumerable<string> extn_paths = has_extn_ref ? extensionPaths : new string [] { null };
 			bool import_needed = false;
 			var currentLoadSettings = project.ProjectLoadSettings;
-			
+
 			try {
-				foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings}) {
+				foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings }) {
 					foreach (string path in extn_paths) {
 						string extn_msg = null;
 						if (has_extn_ref) {
@@ -183,7 +194,7 @@ string GetFullPath ()
 						// We stop if atleast one file got imported.
 						// Remaining extension paths are *not* tried
 						bool atleast_one = false;
-						foreach (string importPath in GetImportPathsFromString (project_attribute, project, base_dir_info)) {
+						foreach (string importPath in importPaths) {
 							try {
 								if (func (importPath, extn_msg))
 									atleast_one = true;

   Commit: b8a031d583c932d3c5d025386e75bc86cf04ad5b
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-10-02 15:12:29 GMT
      URL: https://github.com/mono/mono/commit/b8a031d583c932d3c5d025386e75bc86cf04ad5b

[xBuild] Add missing VisualStudioVersion propety which was introduced in VS2012

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
@@ -1032,7 +1032,9 @@ void InitializeProperties (string effective_tools_version)
 			SetExtensionsPathProperties (DefaultExtensionsPath);
 			evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
 			evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
-#if NET_4_5	
+#if NET_4_5
+			// impersonate Visual Studio 2012. see http://blogs.msdn.com/b/webdev/archive/2012/08/22/visual-studio-project-compatability-and-visualstudioversion.aspx
+			evaluatedProperties.AddProperty (new BuildProperty ("VisualStudioVersion", "11.0", PropertyType.Reserved));
 			// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
 			if (effective_tools_version == "12.0") {
 				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));

   Commit: 0fd61547a110620851da255e32931ffd846d8dce
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-10-04 09:49:00 GMT
      URL: https://github.com/mono/mono/commit/0fd61547a110620851da255e32931ffd846d8dce

[xBuild] Don't set any VisualStudioVersion

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
@@ -1033,8 +1033,6 @@ void InitializeProperties (string effective_tools_version)
 			evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
 			evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
 #if NET_4_5
-			// impersonate Visual Studio 2012. see http://blogs.msdn.com/b/webdev/archive/2012/08/22/visual-studio-project-compatability-and-visualstudioversion.aspx
-			evaluatedProperties.AddProperty (new BuildProperty ("VisualStudioVersion", "11.0", PropertyType.Reserved));
 			// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
 			if (effective_tools_version == "12.0") {
 				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));

   Commit: 6c8c17c9323c0426f4a844d90e0f5a95844e6630
   Author: Gustavo Guerra <[email protected]> (ovatsus)
     Date: 2013-10-09 12:38:35 GMT
      URL: https://github.com/mono/mono/commit/6c8c17c9323c0426f4a844d90e0f5a95844e6630

Adjust defines to check for 4_0 instead of 3_0

Changed paths:
  M mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs

Modified: mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
===================================================================
@@ -48,7 +48,7 @@ static ToolLocationHelper ()
 			t2 = t1.Parent;
 
 			lib_mono_dir = t2.FullName;
-#if NET_3_0
+#if NET_4_0
 			var windowsPath = Environment.GetFolderPath (Environment.SpecialFolder.Windows);
 #endif
 			if (Environment.GetEnvironmentVariable ("TESTING_MONO") != null) {
@@ -60,7 +60,7 @@ static ToolLocationHelper ()
 					Path.Combine (lib_mono_dir, "net_4_0"),
 					Path.Combine (lib_mono_dir, "net_4_5")
 				};	
-#if NET_3_0
+#if NET_4_0
 			} else if (!string.IsNullOrEmpty (windowsPath) && lib_mono_dir.StartsWith (windowsPath)) {
 				//running in .NET, not Mono
 				mono_dir = new string [] {
@@ -108,7 +108,7 @@ public static string GetPathToDotNetFramework (TargetDotNetFrameworkVersion vers
 			return mono_dir [(int)version];
 		}
 
-#if NET_3_0
+#if NET_4_0
 		public static string GetMSBuildInstallPath (string version)
 		{
 			//see http://msdn.microsoft.com/en-us/library/vstudio/bb397428(v=vs.120).aspx

   Commit: 0075f3921505d5a52e163992c41842f809499d2a
   Author: Atsushi Eno <[email protected]> (atsushieno)
     Date: 2013-10-18 07:48:26 GMT
      URL: https://github.com/mono/mono/commit/0075f3921505d5a52e163992c41842f809499d2a

Merge pull request #767 from ovatsus/Bug14922

Fix for #14922

Changed paths:
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionFactorExpresion.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
  M mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
  M mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionFactorExpresion.cs
===================================================================
@@ -109,6 +109,11 @@ public override bool CanEvaluateToNumber (Project context)
 		{
 			if (token.Type == TokenType.Number)
 				return true;
+			else if (token.Type == TokenType.String) {
+				var text = StringEvaluate (context);
+				Single number;
+				return Single.TryParse (text, out number);
+			}
 			else
 				return false;
 		}

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs
===================================================================
@@ -96,14 +96,17 @@ public void Scan ()
 					return;
 
 				int offset = 0;
+				string full_path;
 				if (Path.IsPathRooted (name)) {
+					full_path = name;
 					baseDirectory = new DirectoryInfo (Path.GetPathRoot (name));
 					if (IsRunningOnWindows)
 						// skip the "drive:"
 						offset = 1;
+				} else {
+					full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, name));
 				}
 
-				string full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, include_item.ItemSpec));
 				fileInfo = ParseIncludeExclude (separatedPath, offset, baseDirectory);
 
 				int wildcard_offset = full_path.IndexOf ("**");

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
===================================================================
@@ -118,6 +118,11 @@ void LoadDefaultToolsets ()
 			Toolsets.Add (new Toolset ("4.0",
 						ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
 #endif
+#if NET_4_5
+			Toolsets.Add (new Toolset("12.0",
+						ToolLocationHelper.GetMSBuildInstallPath ("12.0"),
+						ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
+#endif
 		}
 		
 		[MonoTODO]

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
===================================================================
@@ -159,12 +159,23 @@ string GetFullPath ()
 			else
 				base_dir_info = new DirectoryInfo (Directory.GetCurrentDirectory ());
 
-			IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
+			var importPaths = GetImportPathsFromString (project_attribute, project, base_dir_info);
+			var extensionPaths = GetExtensionPaths (project);
+
+			if (!has_extn_ref) {
+				foreach (var importPath in importPaths) {
+					foreach (var extensionPath in extensionPaths) {
+						has_extn_ref = has_extn_ref || importPath.IndexOf (extensionPath) >= 0;
+					}
+				}
+			}
+
+			IEnumerable<string> extn_paths = has_extn_ref ? extensionPaths : new string [] { null };
 			bool import_needed = false;
 			var currentLoadSettings = project.ProjectLoadSettings;
-			
+
 			try {
-				foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings}) {
+				foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings }) {
 					foreach (string path in extn_paths) {
 						string extn_msg = null;
 						if (has_extn_ref) {
@@ -183,7 +194,7 @@ string GetFullPath ()
 						// We stop if atleast one file got imported.
 						// Remaining extension paths are *not* tried
 						bool atleast_one = false;
-						foreach (string importPath in GetImportPathsFromString (project_attribute, project, base_dir_info)) {
+						foreach (string importPath in importPaths) {
 							try {
 								if (func (importPath, extn_msg))
 									atleast_one = true;

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
@@ -937,6 +937,9 @@ internal void ProcessElements (XmlElement rootElement, ImportedProject ip)
 					case "Import":
 						AddImport (xe, ip, true);
 						break;
+					case "ImportGroup":
+						AddImportGroup (xe, ip, true);
+						break;
 					case "ItemGroup":
 						AddItemGroup (xe, ip);
 						break;
@@ -947,7 +950,7 @@ internal void ProcessElements (XmlElement rootElement, ImportedProject ip)
 						AddChoose (xe, ip);
 						break;
 					default:
-						throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file.", xe.Name));
+						throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file '{1}'.", xe.Name, ip.FullFileName));
 					}
 				}
 			}
@@ -1029,7 +1032,17 @@ void InitializeProperties (string effective_tools_version)
 			SetExtensionsPathProperties (DefaultExtensionsPath);
 			evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
 			evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
-
+#if NET_4_5
+			// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
+			if (effective_tools_version == "12.0") {
+				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));
+				string frameworkToolsPath = parentEngine.Toolsets [effective_tools_version].FrameworkToolsPath;
+				if (frameworkToolsPath == null)
+					throw new Exception (String.Format ("Invalid tools version '{0}', no framework tools path set for this.", effective_tools_version));				
+				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildFrameworkToolsPath", frameworkToolsPath, PropertyType.Reserved));
+				evaluatedProperties.AddProperty (new BuildProperty ("MSBuildFrameworkToolsPath32", frameworkToolsPath, PropertyType.Reserved));
+			}
+#endif
 			// FIXME: make some internal method that will work like GetDirectoryName but output String.Empty on null/String.Empty
 			string projectDir;
 			if (FullFileName == String.Empty)
@@ -1104,9 +1117,10 @@ void AddUsingTask (XmlElement xmlElement, ImportedProject importedProject)
 		void AddImport (XmlElement xmlElement, ImportedProject importingProject, bool evaluate_properties)
 		{
 			// eval all the properties etc till the import
-			if (evaluate_properties)
+			if (evaluate_properties) {
 				groupingCollection.Evaluate (EvaluationType.Property);
-
+				groupingCollection.Evaluate (EvaluationType.Choose);
+			}
 			try {
 				PushThisFileProperty (importingProject != null ? importingProject.FullFileName : FullFileName);
 
@@ -1121,6 +1135,30 @@ void AddImport (XmlElement xmlElement, ImportedProject importingProject, bool ev
 			}
 		}
 
+		void AddImportGroup (XmlElement xmlElement, ImportedProject importedProject, bool evaluate_properties)
+		{
+			// eval all the properties etc till the import group
+			if (evaluate_properties) {
+				groupingCollection.Evaluate (EvaluationType.Property);
+				groupingCollection.Evaluate (EvaluationType.Choose);
+			}
+			string condition_attribute = xmlElement.GetAttribute ("Condition");
+			if (!ConditionParser.ParseAndEvaluate (condition_attribute, this))
+				return;
+			foreach (XmlNode xn in xmlElement.ChildNodes) {
+				if (xn is XmlElement) {
+					XmlElement xe = (XmlElement) xn;
+					switch (xe.Name) {
+					case "Import":
+						AddImport (xe, importedProject, evaluate_properties);
+						break;
+					default:
+						throw new InvalidProjectFileException(String.Format("Invalid element '{0}' inside ImportGroup in project file '{1}'.", xe.Name, importedProject.FullFileName));
+					}
+				}
+			}
+		}
+
 		bool AddSingleImport (XmlElement xmlElement, string projectPath, ImportedProject importingProject, string from_source_msg)
 		{
 			Import import = new Import (xmlElement, projectPath, this, importingProject);

Modified: mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
===================================================================
@@ -31,15 +31,21 @@ namespace Microsoft.Build.BuildEngine
 {
 	public class Toolset
 	{
-		public Toolset (string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
+		public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath, BuildPropertyGroup buildProperties)
 		{
 			ToolsVersion = toolsVersion;
 			ToolsPath = toolsPath;
+			FrameworkToolsPath = toolsFrameworkPath;
 			BuildProperties = buildProperties;
 		}
-		
-		public Toolset (string toolsVersion, string toolsPath)
-			: this (toolsVersion, toolsPath, null)
+
+		public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath)
+			: this (toolsVersion, toolsPath, toolsFrameworkPath, null)
+		{
+		}
+
+		public Toolset(string toolsVersion, string toolsPath)
+			: this (toolsVersion, toolsPath, toolsPath)
 		{
 		}
 
@@ -47,5 +53,6 @@ public Toolset (string toolsVersion, string toolsPath)
 
 		public string ToolsVersion { get; private set; }
 		public string ToolsPath { get; private set; }
+		public string FrameworkToolsPath { get; private set; }		
 	}
 }

Modified: mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
===================================================================
@@ -48,6 +48,9 @@ static ToolLocationHelper ()
 			t2 = t1.Parent;
 
 			lib_mono_dir = t2.FullName;
+#if NET_4_0
+			var windowsPath = Environment.GetFolderPath (Environment.SpecialFolder.Windows);
+#endif
 			if (Environment.GetEnvironmentVariable ("TESTING_MONO") != null) {
 				mono_dir = new string [] {
 					Path.Combine (lib_mono_dir, "net_1_0"),
@@ -57,6 +60,18 @@ static ToolLocationHelper ()
 					Path.Combine (lib_mono_dir, "net_4_0"),
 					Path.Combine (lib_mono_dir, "net_4_5")
 				};	
+#if NET_4_0
+			} else if (!string.IsNullOrEmpty (windowsPath) && lib_mono_dir.StartsWith (windowsPath)) {
+				//running in .NET, not Mono
+				mono_dir = new string [] {
+					Path.Combine (lib_mono_dir, "v1.0.3705"),
+					Path.Combine (lib_mono_dir, "v2.0.50727"),
+					Path.Combine (lib_mono_dir, "v2.0.50727"),
+					Path.Combine (lib_mono_dir, "v3.5"),
+					Path.Combine (lib_mono_dir, "v4.0.30319"),
+					Path.Combine (lib_mono_dir, "v4.0.30319")
+				};
+#endif
 			} else {
 				mono_dir = new string [] {
 					Path.Combine (lib_mono_dir, "1.0"),
@@ -93,6 +108,15 @@ public static string GetPathToDotNetFramework (TargetDotNetFrameworkVersion vers
 			return mono_dir [(int)version];
 		}
 
+#if NET_4_0
+		public static string GetMSBuildInstallPath (string version)
+		{
+			//see http://msdn.microsoft.com/en-us/library/vstudio/bb397428(v=vs.120).aspx
+			var programFiles = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
+			return Path.Combine (programFiles, "MSBuild", version, "bin");
+		}
+#endif
+
 		[MonoTODO]
 		public static string GetPathToDotNetFrameworkFile (string fileName,
 								  TargetDotNetFrameworkVersion version)


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.