Skip to content

Commit 73121ee

Browse files
jonathanpeppersjonpryor
authored andcommitted
[xabuild] Build .NET standard projects (#1011)
Context: https://github.com/Microsoft/msbuild/blob/master/src/Shared/BuildEnvironmentHelper.cs#L511 `xabuild.exe` did not support building .NET standard projects. It turns out a `$MSBuildSDKPaths` environment variable needed to be set for locating the `Sdks` directory. On Windows, this path is relative to Visual Studio / MSBuild, but on Mac I had to hardcode the path to .NET Core. It seems to use the same path on Linux as well.
1 parent 628672f commit 73121ee

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tools/xabuild/XABuild.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static XmlDocument CreateConfig (XABuildPaths paths)
103103

104104
xml.Save (paths.XABuildConfig);
105105

106+
Environment.SetEnvironmentVariable ("MSBuildSDKsPath", paths.MSBuildSdksPath, EnvironmentVariableTarget.Process);
106107
Environment.SetEnvironmentVariable ("MSBUILD_EXE_PATH", paths.MSBuildExeTempPath, EnvironmentVariableTarget.Process);
107108
return xml;
108109
}

tools/xabuild/XABuildPaths.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class XABuildPaths
6666
/// </summary>
6767
public string MSBuildExtensionsPath { get; private set; }
6868

69+
/// <summary>
70+
/// Used as the MSBuildSDKsPath environment variable, required for .NET standard projects to build
71+
/// </summary>
72+
public string MSBuildSdksPath { get; private set; }
73+
6974
/// <summary>
7075
/// Array of search paths for MSBuildExtensionsPath
7176
/// </summary>
@@ -113,6 +118,7 @@ public XABuildPaths ()
113118
MSBuildPath = Path.Combine (VsInstallRoot, "MSBuild");
114119
MSBuildBin = Path.Combine (MSBuildPath, "15.0", "Bin");
115120
MSBuildConfig = Path.Combine (MSBuildBin, "MSBuild.exe.config");
121+
MSBuildSdksPath = Path.Combine (MSBuildPath, "Sdks");
116122
ProjectImportSearchPaths = new [] { MSBuildPath, "$(MSBuildProgramFiles32)\\MSBuild" };
117123
SystemProfiles = Path.Combine (programFiles, "Reference Assemblies", "Microsoft", "Framework");
118124
SearchPathsOS = "windows";
@@ -122,6 +128,7 @@ public XABuildPaths ()
122128
MSBuildPath = Path.Combine (mono, "msbuild");
123129
MSBuildBin = Path.Combine (MSBuildPath, "15.0", "bin");
124130
MSBuildConfig = Path.Combine (MSBuildBin, "MSBuild.dll.config");
131+
MSBuildSdksPath = "/usr/local/share/dotnet/sdk/2.0.0/Sdks";
125132
ProjectImportSearchPaths = new [] { MSBuildPath, Path.Combine (mono, "xbuild"), Path.Combine (monoExternal, "xbuild") };
126133
SystemProfiles = Path.Combine (mono, "xbuild-frameworks");
127134
SearchPathsOS = IsMacOS ? "osx" : "unix";

0 commit comments

Comments
 (0)