Skip to content

Commit

Permalink
[xBuild] Support ToolsVersion 12
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gustavo Guerra committed Sep 29, 2013
1 parent b52c963 commit b9a4200
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
Expand Up @@ -117,6 +117,11 @@ void LoadDefaultToolsets ()
#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
}

Expand Down
Expand Up @@ -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)
Expand Down
Expand Up @@ -31,21 +31,28 @@ 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)
{
}

public BuildPropertyGroup BuildProperties { get; private set; }

public string ToolsVersion { get; private set; }
public string ToolsPath { get; private set; }
public string FrameworkToolsPath { get; private set; }
}
}
Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down Expand Up @@ -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)
Expand Down

1 comment on commit b9a4200

@mhutch
Copy link
Member

@mhutch mhutch commented on b9a4200 Dec 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit includes a number of API additions which breaks compatibility with MSBuild.

Please sign in to comment.