[xBuild] Support ToolsVersion 12
authorGustavo Guerra <gustavo@codebeside.org>
Sun, 29 Sep 2013 20:13:58 +0000 (21:13 +0100)
committerGustavo Guerra <gustavo@codebeside.org>
Sun, 29 Sep 2013 20:13:58 +0000 (21:13 +0100)
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

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs

index 51b9f4588a79c7344fe8200cb72f893339633c5f..577a4379d291aeb102a47e97ecb2d288150222a4 100644 (file)
@@ -117,6 +117,11 @@ namespace Microsoft.Build.BuildEngine {
 #if NET_4_0
                        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
                }
                
index 5b6d2553c869045b67cd1e3a5676d69f1c9043b3..7fadbbfcdda55b3fcf394d5549c5c37dbd730159 100644 (file)
@@ -1029,7 +1029,17 @@ namespace Microsoft.Build.BuildEngine {
                        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)
index 5db46fcbfbd5fa6b2c02dc966ca9775f1925198f..0957f298c500fe263bdcda07fa25cbc0e5d32bd9 100644 (file)
@@ -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 @@ namespace Microsoft.Build.BuildEngine
 
                public string ToolsVersion { get; private set; }
                public string ToolsPath { get; private set; }
+               public string FrameworkToolsPath { get; private set; }          
        }
 }
index cc5b84cb90436a63821c0342add8b9ba3bc8a8ea..730d88233e1131332857320a6d216587d175e461 100644 (file)
@@ -48,6 +48,7 @@ namespace Microsoft.Build.Utilities
                        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 @@ namespace Microsoft.Build.Utilities
                                        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 @@ namespace Microsoft.Build.Utilities
                        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)