Skip to content

Commit 6401a60

Browse files
authored
Merge branch 'master' into versioned-document-highlight
2 parents 4164336 + 7c727c8 commit 6401a60

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

build.cake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ string PublishBuild(string project, BuildEnvironment env, BuildPlan plan, string
977977
{
978978
Framework = framework,
979979
Runtime = rid, // TODO: With everything today do we need to publish this with a rid? This appears to be legacy bit when we used to push for all supported dotnet core rids.
980+
PublishReadyToRun = true, // Improve startup performance by applying some AOT compilation
981+
SelfContained = false, // Since we are specifying a runtime identifier this defaults to true. We don't need to ship a runtime for net6 because we require the .NET SDK to be installed.
980982
Configuration = configuration,
981983
OutputDirectory = outputFolder,
982984
MSBuildSettings = new DotNetCoreMSBuildSettings()

src/OmniSharp.Host/HostHelpers.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using Microsoft.Extensions.Logging;
3+
using OmniSharp.MSBuild.Discovery;
34
using OmniSharp.Roslyn;
45
using OmniSharp.Utilities;
56

@@ -28,6 +29,11 @@ public static int Start(Func<int> action)
2829

2930
return action();
3031
}
32+
catch (MSBuildNotFoundException mnfe)
33+
{
34+
Console.Error.WriteLine(mnfe.Message);
35+
return 0xbad;
36+
}
3137
catch (Exception e)
3238
{
3339
Console.Error.WriteLine(e.ToString());

src/OmniSharp.Host/MSBuild/Discovery/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Try updating your MSBuild to version {minimumMSBuildVersion} or higher to enable
7272
}
7373
else
7474
{
75-
logger.LogError("Could not locate MSBuild instance to register with OmniSharp");
75+
throw new MSBuildNotFoundException("Could not locate MSBuild instance to register with OmniSharp.");
7676
}
7777
}
7878

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace OmniSharp.MSBuild.Discovery
4+
{
5+
internal class MSBuildNotFoundException : Exception
6+
{
7+
public MSBuildNotFoundException()
8+
{
9+
}
10+
11+
public MSBuildNotFoundException(string message) : base(message)
12+
{
13+
}
14+
15+
public MSBuildNotFoundException(string message, Exception innerException) : base(message, innerException)
16+
{
17+
}
18+
}
19+
}

src/OmniSharp.Host/MSBuild/Discovery/Providers/MicrosoftBuildLocatorInstanceProvider.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ public override ImmutableArray<MSBuildInstance> GetInstances()
2222
{
2323

2424
#if NETCOREAPP
25+
const string DotNetSdkVersion = "6.0.100";
26+
2527
// Restrict instances to NET 6 SDK
2628
var instances = MicrosoftBuildLocator.QueryVisualStudioInstances()
27-
.Where(instance => instance.Version.Major == 6);
29+
.Where(instance => instance.Version.ToString() == DotNetSdkVersion)
30+
.ToImmutableArray();
31+
32+
if (instances.Length == 0)
33+
{
34+
Logger.LogError($"OmniSharp requires .NET SDK version '{DotNetSdkVersion}' be installed. Please visit https://dotnet.microsoft.com/download/dotnet/6.0 to download the .NET SDK.");
35+
}
2836
#else
2937
if (!PlatformHelper.IsWindows)
3038
{

0 commit comments

Comments
 (0)