Skip to content

Commit

Permalink
Merge pull request #1145 from DustinCampbell/update-msbuild
Browse files Browse the repository at this point in the history
Update OmniSharp to latest MSBuild
  • Loading branch information
DustinCampbell authored Apr 6, 2018
2 parents fdfa303 + 11ab9d6 commit c8e6dbc
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 36 deletions.
1 change: 0 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
<clear />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="dotnet-cli" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
</packageSources>
</configuration>
69 changes: 57 additions & 12 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,40 @@ Task("CreateMSBuildFolder")
CopyDotNetHostResolver(env, "linux", "x64", "libhostfxr.so", sdkResolverTargetFolder, copyToArchSpecificFolder: false);
}

// Copy content of NuGet.Build.Tasks
var nugetBuildTasksFolder = CombinePaths(env.Folders.Tools, "NuGet.Build.Tasks");
var nugetBuildTasksBinariesFolder = CombinePaths(nugetBuildTasksFolder, "lib", "net46");
var nugetBuildTasksTargetsFolder = CombinePaths(nugetBuildTasksFolder, "runtimes", "any", "native");

FileHelper.Copy(
source: CombinePaths(nugetBuildTasksBinariesFolder, "NuGet.Build.Tasks.dll"),
destination: CombinePaths(msbuild15BinTargetFolder, "NuGet.Build.Tasks.dll"));

FileHelper.Copy(
source: CombinePaths(nugetBuildTasksTargetsFolder, "NuGet.targets"),
destination: CombinePaths(msbuild15BinTargetFolder, "NuGet.targets"));

// Copy dependencies of NuGet.Build.Tasks
var nugetPackages = new []
{
"NuGet.Commands",
"NuGet.Common",
"NuGet.Configuration",
"NuGet.Frameworks",
"NuGet.ProjectModel",
"NuGet.Protocol",
"NuGet.Versioning"
};

foreach (var nugetPackage in nugetPackages)
{
var binaryName = nugetPackage + ".dll";

FileHelper.Copy(
source: CombinePaths(env.Folders.Tools, nugetPackage, "lib", "net46", binaryName),
destination: CombinePaths(msbuild15BinTargetFolder, binaryName));
}

// Copy content of Microsoft.Net.Compilers
Information("Copying Microsoft.Net.Compilers...");
var compilersSourceFolder = CombinePaths(env.Folders.Tools, "Microsoft.Net.Compilers", "tools");
Expand Down Expand Up @@ -632,8 +666,11 @@ Task("Test")
else
{
// Copy the Mono-built Microsoft.Build.* binaries to the test folder.
// This is necessary to work around a Mono bug that is exasperated by xUnit.
DirectoryHelper.Copy($"{env.Folders.MonoMSBuildLib}", instanceFolder);

DeleteUnnecessaryAssemblies(instanceFolder);

var runScript = CombinePaths(env.Folders.Mono, "run");

// By default, the run script launches OmniSharp. To launch our Mono runtime
Expand All @@ -649,6 +686,25 @@ Task("Test")
}
});

/// <summary>
/// Delete assemblies that are included in our Mono package.
/// </summary>
void DeleteUnnecessaryAssemblies(string folder)
{
FileHelper.Delete(CombinePaths(folder, "System.AppContext.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Numerics.Vectors.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Runtime.InteropServices.RuntimeInformation.dll"));
FileHelper.Delete(CombinePaths(folder, "System.ComponentModel.Primitives.dll"));
FileHelper.Delete(CombinePaths(folder, "System.ComponentModel.TypeConverter.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Console.dll"));
FileHelper.Delete(CombinePaths(folder, "System.IO.FileSystem.Primitives.dll"));
FileHelper.Delete(CombinePaths(folder, "System.IO.FileSystem.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Security.Cryptography.Encoding.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Security.Cryptography.Primitives.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Security.Cryptography.X509Certificates.dll"));
FileHelper.Delete(CombinePaths(folder, "System.Threading.Thread.dll"));
}

void CopyMonoBuild(BuildEnvironment env, string sourceFolder, string outputFolder)
{
DirectoryHelper.Copy(sourceFolder, outputFolder, copySubDirectories: false);
Expand All @@ -657,18 +713,7 @@ void CopyMonoBuild(BuildEnvironment env, string sourceFolder, string outputFolde
DirectoryHelper.Copy($"{env.Folders.MSBuild}", CombinePaths(outputFolder, "msbuild"));

// Included in Mono
FileHelper.Delete(CombinePaths(outputFolder, "System.AppContext.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Numerics.Vectors.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Runtime.InteropServices.RuntimeInformation.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.ComponentModel.Primitives.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.ComponentModel.TypeConverter.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Console.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.IO.FileSystem.Primitives.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.IO.FileSystem.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Security.Cryptography.Encoding.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Security.Cryptography.Primitives.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Security.Cryptography.X509Certificates.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Threading.Thread.dll"));
DeleteUnnecessaryAssemblies(outputFolder);
}

string PublishMonoBuild(string project, BuildEnvironment env, BuildPlan plan, string configuration)
Expand Down
4 changes: 2 additions & 2 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"MonoRuntimeLinux32": "mono.linux-x86-5.10.1.20.zip",
"MonoRuntimeLinux64": "mono.linux-x86_64-5.10.1.20.zip",
"MonoFramework": "framework-5.10.1.20.zip",
"MonoMSBuildRuntime": "Microsoft.Build.Runtime.Mono-alpha6.zip",
"MonoMSBuildLib": "Microsoft.Build.Lib.Mono-alpha6.zip",
"MonoMSBuildRuntime": "Microsoft.Build.Runtime.Mono-mono-5.10.1.20.zip",
"MonoMSBuildLib": "Microsoft.Build.Lib.Mono-mono-5.10.1.20.zip",
"HostProjects": [
"OmniSharp.Stdio",
"OmniSharp.Http"
Expand Down
8 changes: 4 additions & 4 deletions build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<MicrosoftAspNetCoreHostingVersion>1.1.0</MicrosoftAspNetCoreHostingVersion>
<MicrosoftAspNetCoreHttpFeaturesVersion>1.1.0</MicrosoftAspNetCoreHttpFeaturesVersion>
<MicrosoftAspNetCoreServerKestrelVersion>1.1.0</MicrosoftAspNetCoreServerKestrelVersion>
<MicrosoftBuildVersion>15.3.409</MicrosoftBuildVersion>
<MicrosoftBuildFrameworkVersion>15.3.409</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildTasksCoreVersion>15.3.409</MicrosoftBuildTasksCoreVersion>
<MicrosoftBuildUtilitiesCoreVersion>15.3.409</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftBuildVersion>15.6.82</MicrosoftBuildVersion>
<MicrosoftBuildFrameworkVersion>15.6.82</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildTasksCoreVersion>15.6.82</MicrosoftBuildTasksCoreVersion>
<MicrosoftBuildUtilitiesCoreVersion>15.6.82</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftCodeAnalysisCommonVersion>2.7.0</MicrosoftCodeAnalysisCommonVersion>
<MicrosoftCodeAnalysisCSharpVersion>2.7.0</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisCSharpFeaturesVersion>2.7.0</MicrosoftCodeAnalysisCSharpFeaturesVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,29 @@ public override ImmutableArray<MSBuildInstance> GetInstances()

var propertyOverrides = ImmutableDictionary.CreateBuilder<string, string>(StringComparer.OrdinalIgnoreCase);

// To better support older versions of Mono that don't include
// MSBuild 15, we attempt to set property overrides to the locations
// of Mono's 'xbuild' and 'xbuild-frameworks' paths.
if (_allowMonoPaths && PlatformHelper.IsMono)
if (PlatformHelper.IsMono)
{
if (TryGetMonoXBuildPath(out var xbuildPath))
// This disables a hack in the "GetReferenceAssemblyPaths" task which attempts
// guarantee that .NET Framework SP1 is installed when the target framework is
// .NET Framework, but the version is less than 4.0. The hack attempts to locate
// a particular assembly in the GAC as a "guarantee". However, we don't include that
// in our Mono package. So, we'll just bypass the check.
propertyOverrides.Add("BypassFrameworkInstallChecks", "true");

// To better support older versions of Mono that don't include
// MSBuild 15, we attempt to set property overrides to the locations
// of Mono's 'xbuild' and 'xbuild-frameworks' paths.
if (_allowMonoPaths)
{
extensionsPath = xbuildPath;
}

if (TryGetMonoXBuildFrameworksPath(out var xbuildFrameworksPath))
{
propertyOverrides.Add("TargetFrameworkRootPath", xbuildFrameworksPath);
if (TryGetMonoXBuildPath(out var xbuildPath))
{
extensionsPath = xbuildPath;
}

if (TryGetMonoXBuildFrameworksPath(out var xbuildFrameworksPath))
{
propertyOverrides.Add("TargetFrameworkRootPath", xbuildFrameworksPath);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/OmniSharp.MSBuild/ProjectFile/PropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal static class PropertyNames
public const string AssemblyOriginatorKeyFile = nameof(AssemblyOriginatorKeyFile);
public const string BuildProjectReferences = nameof(BuildProjectReferences);
public const string BuildingInsideVisualStudio = nameof(BuildingInsideVisualStudio);
public const string BypassFrameworkInstallChecks = nameof(BypassFrameworkInstallChecks);
public const string Configuration = nameof(Configuration);
public const string CscToolExe = nameof(CscToolExe);
public const string CscToolPath = nameof(CscToolPath);
Expand Down
5 changes: 5 additions & 0 deletions src/OmniSharp.MSBuild/ProjectLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ private static Dictionary<string, string> CreateGlobalProperties(
globalProperties.AddPropertyOverride(PropertyNames.Configuration, options.Configuration, propertyOverrides, logger);
globalProperties.AddPropertyOverride(PropertyNames.Platform, options.Platform, propertyOverrides, logger);

if (propertyOverrides.TryGetValue(PropertyNames.BypassFrameworkInstallChecks, out var value))
{
globalProperties.Add(PropertyNames.BypassFrameworkInstallChecks, value);
}

return globalProperties;
}

Expand Down
20 changes: 14 additions & 6 deletions tools/packages.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.23" />
<package id="Microsoft.Build" version="15.3.409" />
<package id="Microsoft.Build.Framework" version="15.3.409" />
<package id="Microsoft.Build.Runtime" version="15.3.409" />
<package id="Microsoft.Build.Tasks.Core" version="15.3.409" />
<package id="Microsoft.Build.Utilities.Core" version="15.3.409" />
<package id="Microsoft.Net.Compilers" version="2.3.2" />
<package id="Microsoft.Build" version="15.6.82" />
<package id="Microsoft.Build.Framework" version="15.6.82" />
<package id="Microsoft.Build.Runtime" version="15.6.82" />
<package id="Microsoft.Build.Tasks.Core" version="15.6.82" />
<package id="Microsoft.Build.Utilities.Core" version="15.6.82" />
<package id="Microsoft.Net.Compilers" version="2.7.0" />
<package id="Microsoft.DotNet.MSBuildSdkResolver" version="2.1.300-preview2-008523" />
<package id="NuGet.Build.Tasks" version="4.6.1" />
<package id="NuGet.Commands" version="4.6.1" />
<package id="NuGet.Common" version="4.6.1" />
<package id="NuGet.Configuration" version="4.6.1" />
<package id="NuGet.Frameworks" version="4.6.1" />
<package id="NuGet.ProjectModel" version="4.6.1" />
<package id="NuGet.Protocol" version="4.6.1" />
<package id="NuGet.Versioning" version="4.6.1" />
<package id="runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver" version="2.1.0-preview3-26404-02" />
<package id="runtime.osx-x64.Microsoft.NETCore.DotNetHostResolver" version="2.1.0-preview3-26404-02" />
<package id="runtime.win-x64.Microsoft.NETCore.DotNetHostResolver" version="2.1.0-preview3-26404-02" />
Expand Down

0 comments on commit c8e6dbc

Please sign in to comment.