Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade http driver to latest ASP.NET Core version when running in .NET 6 #2446

Merged
merged 2 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<AspNetCorePackageVersion>2.2.0</AspNetCorePackageVersion>
<MicrosoftExtensionPackageVersion>6.0.0</MicrosoftExtensionPackageVersion>
<MicrosoftTestPackageVersion>17.3.0</MicrosoftTestPackageVersion>
<MSBuildPackageVersion>17.3.1</MSBuildPackageVersion>
Expand All @@ -20,11 +19,6 @@

<PackageReference Update="McMaster.Extensions.CommandLineUtils" Version="3.1.0" />

<PackageReference Update="Microsoft.AspNetCore.Diagnostics" Version="$(AspNetCorePackageVersion)" />
<PackageReference Update="Microsoft.AspNetCore.Hosting" Version="$(AspNetCorePackageVersion)" />
<PackageReference Update="Microsoft.AspNetCore.Http.Features" Version="$(AspNetCorePackageVersion)" />
<PackageReference Update="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCorePackageVersion)" />

<PackageReference Update="Microsoft.Build" Version="$(MSBuildPackageVersion)" />
<PackageReference Update="Microsoft.Build.Framework" Version="$(MSBuildPackageVersion)" />
<PackageReference Update="Microsoft.Build.Tasks.Core" Version="$(MSBuildPackageVersion)" />
Expand Down Expand Up @@ -94,5 +88,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Update="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.Http.Features" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
</ItemGroup>
</Project>

13 changes: 13 additions & 0 deletions src/OmniSharp.Http/Host.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Diagnostics;
using Microsoft.AspNetCore.Hosting;
#if NETCOREAPP
using Microsoft.Extensions.Hosting;
#endif
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OmniSharp.Eventing;
Expand Down Expand Up @@ -38,7 +41,13 @@ public void Start()
.AddCommandLine(new[] { "--server.urls", $"http://{_serverInterface}:{_serverPort}" });

var builder = new WebHostBuilder()
#if NETCOREAPP
.UseKestrel(config => {
config.AllowSynchronousIO = true;
})
#else
.UseKestrel()
#endif
.ConfigureServices(serviceCollection =>
{
serviceCollection.AddSingleton(_environment);
Expand All @@ -56,7 +65,11 @@ public void Start()
{
app.Start();

#if NETCOREAPP
var appLifeTime = app.Services.GetRequiredService<IHostApplicationLifetime>();
#else
var appLifeTime = app.Services.GetRequiredService<IApplicationLifetime>();
#endif

Console.CancelKeyPress += (sender, e) =>
{
Expand Down
10 changes: 10 additions & 0 deletions src/OmniSharp.Http/Middleware/StopServerMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
using System.Threading;
using System.Threading.Tasks;
#if NETCOREAPP
using Microsoft.Extensions.Hosting;
#else
using Microsoft.AspNetCore.Hosting;
#endif
using Microsoft.AspNetCore.Http;

namespace OmniSharp.Http.Middleware
{
class StopServerMiddleware
{
#if NETCOREAPP
private readonly IHostApplicationLifetime _lifetime;

public StopServerMiddleware(RequestDelegate next, IHostApplicationLifetime lifetime)
#else
private readonly IApplicationLifetime _lifetime;

public StopServerMiddleware(RequestDelegate next, IApplicationLifetime lifetime)
#endif
{
_lifetime = lifetime;
}
Expand Down
7 changes: 7 additions & 0 deletions src/OmniSharp.Http/OmniSharp.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net472'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OmniSharp.DotNetTest\OmniSharp.DotNetTest.csproj" />
<ProjectReference Include="..\OmniSharp.Host\OmniSharp.Host.csproj" />
Expand All @@ -14,8 +18,11 @@
<ProjectReference Condition="'$(TargetFramework)' == 'net472'" Include="..\OmniSharp.Cake\OmniSharp.Cake.csproj" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" />
Expand Down