Skip to content

Commit

Permalink
Default MSBuildSDKsPath location to {tools}\Sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
rainersigwald committed Nov 30, 2016
1 parent d83721a commit 9801c6d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/Shared/BuildEnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,19 @@ public BuildEnvironment(string processNameCommandLine, bool runningTests, bool r
/// </summary>
internal string MSBuildToolsDirectory64 { get; private set; }

/// <summary>
/// Path to the Sdks folder for this MSBuild instance.
/// </summary>
internal string MSBuildSDKsPath
{
get
{
// Allow an environment-variable override of the default SDK location
return Environment.GetEnvironmentVariable("MSBuildSDKsPath") ??
Path.Combine(CurrentMSBuildToolsDirectory, "Sdks");
}
}

/// <summary>
/// Full path to the current MSBuild configuration file.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Shared/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ internal static class MSBuildConstants
/// </summary>
internal const string ToolsPath64 = "MSBuildToolsPath64";

/// <summary>
/// Name of the property that indicates the root of the SDKs folder
/// </summary>
internal const string SdksPath = "MSBuildSDKsPath";

/// <summary>
/// The most current Visual Studio Version known to this version of MSBuild.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/XMakeBuildEngine/Definition/ToolsetLocalReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected override IEnumerable<ToolsetPropertyDefinition> ToolsVersions
protected override IEnumerable<ToolsetPropertyDefinition> GetPropertyDefinitions(string toolsVersion)
{
yield return new ToolsetPropertyDefinition(MSBuildConstants.ToolsPath, BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory, _sourceLocation);
yield return new ToolsetPropertyDefinition(MSBuildConstants.SdksPath, BuildEnvironmentHelper.Instance.MSBuildSDKsPath, _sourceLocation);
yield return new ToolsetPropertyDefinition("RoslynTargetsPath", BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory, _sourceLocation);
}

Expand Down
5 changes: 5 additions & 0 deletions src/XMakeBuildEngine/Evaluation/IntrinsicFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ public static string GetToolsDirectory64()
return BuildEnvironmentHelper.Instance.MSBuildToolsDirectory64;
}

public static string GetMSBuildSDKsPath()
{
return BuildEnvironmentHelper.Instance.MSBuildSDKsPath;
}

public static string GetVsInstallRoot()
{
return BuildEnvironmentHelper.Instance.VisualStudioInstallRootDirectory;
Expand Down
6 changes: 2 additions & 4 deletions src/XMakeBuildEngine/Evaluation/ProjectParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ private void ParseProjectElement(XmlElementWithLocation element)

if (element.HasAttribute(XMakeAttributes.sdk))
{
// TODO: don't get root of SDKs from the environment, use a built-in or toolset prop
// TODO: Don't null ref if MSBuildSDKsPath isn't defined

var sdksString = element.GetAttribute(XMakeAttributes.sdk);

Expand All @@ -210,9 +208,9 @@ private void ParseProjectElement(XmlElementWithLocation element)
}

// TODO: paths should just be Sdk.props/targets; Sdk-aware imports should do the rest of the path.
var initialImportPath = Path.Combine(Environment.GetEnvironmentVariable("MSBuildSDKsPath"),
var initialImportPath = Path.Combine(BuildEnvironmentHelper.Instance.MSBuildSDKsPath,
sdkName, "Sdk", "Sdk.props");
var finalImportPath = Path.Combine(Environment.GetEnvironmentVariable("MSBuildSDKsPath"),
var finalImportPath = Path.Combine(BuildEnvironmentHelper.Instance.MSBuildSDKsPath,
sdkName, "Sdk", "Sdk.targets");

if (File.Exists(initialImportPath))
Expand Down
1 change: 1 addition & 0 deletions src/XMakeCommandLine/app.amd64.config
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<property name="MSBuildToolsPath" value="$([MSBuild]::GetCurrentToolsDirectory())" />
<property name="MSBuildToolsPath32" value="$([MSBuild]::GetToolsDirectory32())" />
<property name="MSBuildToolsPath64" value="$([MSBuild]::GetToolsDirectory64())" />
<property name="MSBuildSDKsPath" value="$([MSBuild]::GetMSBuildSDKsPath())" />
<property name="FrameworkSDKRoot" value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1@InstallationFolder)" />
<property name="MSBuildRuntimeVersion" value="4.0.30319" />
<property name="MSBuildFrameworkToolsPath" value="$(SystemRoot)\Microsoft.NET\Framework\v$(MSBuildRuntimeVersion)\" />
Expand Down
1 change: 1 addition & 0 deletions src/XMakeCommandLine/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<property name="MSBuildToolsPath" value="$([MSBuild]::GetCurrentToolsDirectory())" />
<property name="MSBuildToolsPath32" value="$([MSBuild]::GetToolsDirectory32())" />
<property name="MSBuildToolsPath64" value="$([MSBuild]::GetToolsDirectory64())" />
<property name="MSBuildSDKsPath" value="$([MSBuild]::GetMSBuildSDKsPath())" />
<property name="FrameworkSDKRoot" value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1@InstallationFolder)" />
<property name="MSBuildRuntimeVersion" value="4.0.30319" />
<property name="MSBuildFrameworkToolsPath" value="$(SystemRoot)\Microsoft.NET\Framework\v$(MSBuildRuntimeVersion)\" />
Expand Down

0 comments on commit 9801c6d

Please sign in to comment.