diff --git a/src/XMakeBuildEngine/Definition/ToolsetReader.cs b/src/XMakeBuildEngine/Definition/ToolsetReader.cs index 27dab2c02f8..c2b1c13dcc0 100644 --- a/src/XMakeBuildEngine/Definition/ToolsetReader.cs +++ b/src/XMakeBuildEngine/Definition/ToolsetReader.cs @@ -168,15 +168,28 @@ ToolsetDefinitionLocations locations var props = new PropertyDictionary(); var libraryPath = NativeMethodsShared.FrameworkBasePath; - if (!string.IsNullOrEmpty(libraryPath)) - { - libraryPath = Path.GetDirectoryName(libraryPath); - } if (!string.IsNullOrEmpty(libraryPath)) { - var r = new Regex(libraryPath + Path.DirectorySeparatorChar + @"\d+\.\d+"); - foreach (var d in Directory.GetDirectories(libraryPath).Where(d => r.IsMatch(d))) + // The 4.0 toolset is installed in the framework directory + var v4dir = FrameworkLocationHelper.GetPathToDotNetFrameworkV40(DotNetFrameworkArchitecture.Current); + if (v4dir != null) + { + toolsets.Add( + "4.0", + new Toolset( + "4.0", + v4dir, + environmentProperties, + globalProperties, + currentDir, + string.Empty)); + } + + // Other toolsets are installed in the xbuild directory + var xbuildToolsetsDir = Path.Combine(libraryPath, "xbuild"); + var r = new Regex(xbuildToolsetsDir + Path.DirectorySeparatorChar + @"\d+\.\d+"); + foreach (var d in Directory.GetDirectories(xbuildToolsetsDir).Where(d => r.IsMatch(d))) { var version = Path.GetFileName(d); if (version != null && !toolsets.ContainsKey(version)) @@ -185,7 +198,7 @@ ToolsetDefinitionLocations locations version, new Toolset( version, - d, + Path.Combine(d,"bin"), environmentProperties, globalProperties, currentDir,