Skip to content

Commit bbf8ffe

Browse files
authored
Fix running in benchmarks environment with net60 (#1133)
1 parent ac2523f commit bbf8ffe

File tree

9 files changed

+13
-33
lines changed

9 files changed

+13
-33
lines changed

build/sources.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json;
88
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
99
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json;
10+
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;
1011
https://dotnet.myget.org/F/roslyn/api/v3/index.json;
1112
</RestoreSources>
1213
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)feed')">

perf/benchmarkapps/GrpcAspNetCoreServer/GrpcAspNetCoreServer.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
<TargetFramework Condition="'$(BenchmarksTargetFramework)' != ''">$(BenchmarksTargetFramework)</TargetFramework>
65
<OutputType>Exe</OutputType>
76
<!-- Uncomment line below to enable gRPC-Web on the server -->
87
<DefineConstants Condition="'$(EnableGrpcWeb)' == 'true'">$(DefineConstants);GRPC_WEB</DefineConstants>
@@ -13,12 +12,6 @@
1312
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
1413
</PropertyGroup>
1514

16-
<!-- Allow benchmarks to specify the latest framework -->
17-
<ItemGroup Condition="'$(BenchmarksTargetFramework)' != ''">
18-
<FrameworkReference Update="Microsoft.AspNetCore.App" RuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppPackageVersion)" />
19-
<FrameworkReference Update="Microsoft.NETCore.App" RuntimeFrameworkVersion="$(MicrosoftNETCoreAppPackageVersion)" />
20-
</ItemGroup>
21-
2215
<ItemGroup>
2316
<Protobuf Include="..\Shared\benchmark_service.proto" GrpcServices="Server" Link="Protos\benchmark_service.proto" />
2417
<Protobuf Include="..\Shared\messages.proto" GrpcServices="Server" Link="Protos\messages.proto" />
@@ -41,7 +34,7 @@
4134
<ProjectReference Include="..\..\..\src\Grpc.AspNetCore.Web\Grpc.AspNetCore.Web.csproj" />
4235
</ItemGroup>
4336

44-
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
37+
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
4538
<ProjectReference Include="..\..\..\src\Grpc.AspNetCore.Server\Grpc.AspNetCore.Server.csproj" />
4639

4740
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />

perf/benchmarkapps/GrpcAspNetCoreServer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static IHostBuilder CreateHostBuilder(string[] args)
102102
Console.WriteLine($"Console Logging enabled with level '{logLevel}'");
103103

104104
loggerFactory
105-
#if NET5_0
105+
#if NET5_0 || NET6_0
106106
.AddSimpleConsole(o => o.TimestampFormat = "ss.ffff ")
107107
#else
108108
.AddConsole(o => o.TimestampFormat = "ss.ffff ")

perf/benchmarkapps/GrpcAspNetCoreServer/Startup.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
using System.Security.Cryptography.X509Certificates;
2222
using System.Text;
2323
using Grpc.Testing;
24-
#if NET5_0
24+
#if NET5_0 || NET6_0
2525
using Microsoft.AspNetCore.Authentication.Certificate;
2626
#endif
2727
using Microsoft.AspNetCore.Builder;
@@ -47,7 +47,7 @@ public void ConfigureServices(IServiceCollection services)
4747
{
4848
services.AddGrpc(o =>
4949
{
50-
#if NET5_0
50+
#if NET5_0 || NET6_0
5151
// Small performance benefit to not add catch-all routes to handle UNIMPLEMENTED for unknown services
5252
o.IgnoreUnknownServices = true;
5353
#endif
@@ -60,7 +60,7 @@ public void ConfigureServices(IServiceCollection services)
6060
services.AddSingleton<BenchmarkServiceImpl>();
6161
services.AddControllers();
6262

63-
#if NET5_0
63+
#if NET5_0 || NET6_0
6464
bool.TryParse(_config["enableCertAuth"], out var enableCertAuth);
6565
if (enableCertAuth)
6666
{
@@ -83,7 +83,7 @@ public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicat
8383

8484
app.UseRouting();
8585

86-
#if NET5_0
86+
#if NET5_0 || NET6_0
8787
bool.TryParse(_config["enableCertAuth"], out var enableCertAuth);
8888
if (enableCertAuth)
8989
{
@@ -139,7 +139,7 @@ public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicat
139139

140140
private void ConfigureAuthorization(IEndpointConventionBuilder builder)
141141
{
142-
#if NET5_0
142+
#if NET5_0 || NET6_0
143143
bool.TryParse(_config["enableCertAuth"], out var enableCertAuth);
144144
if (enableCertAuth)
145145
{

perf/benchmarkapps/GrpcClient/ClientOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace GrpcClient
2323
public class ClientOptions
2424
{
2525
public string? Url { get; set; }
26-
#if NET5_0
26+
#if NET5_0 || NET6_0
2727
public string? UdsFileName { get; set; }
2828
#endif
2929
public int Connections { get; set; }

perf/benchmarkapps/GrpcClient/GrpcClient.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
<TargetFramework Condition="'$(BenchmarksTargetFramework)' != ''">$(BenchmarksTargetFramework)</TargetFramework>
65
<OutputType>Exe</OutputType>
76
<DefineConstants Condition="'$(EnableGrpcWeb)' == 'true'">$(DefineConstants);GRPC_WEB</DefineConstants>
87
<!-- Enable server GC to more closely simulate a microservice app making calls -->
98
<ServerGarbageCollection>true</ServerGarbageCollection>
109
</PropertyGroup>
1110

12-
<!-- Allow benchmarks to specify the latest framework -->
13-
<ItemGroup Condition="'$(BenchmarksTargetFramework)' != ''">
14-
<FrameworkReference Update="Microsoft.AspNetCore.App" RuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppPackageVersion)" />
15-
<FrameworkReference Update="Microsoft.NETCore.App" RuntimeFrameworkVersion="$(MicrosoftNETCoreAppPackageVersion)" />
16-
</ItemGroup>
17-
1811
<ItemGroup>
1912
<Protobuf Include="..\Shared\benchmark_service.proto" GrpcServices="Client" Link="Protos\benchmark_service.proto" />
2013
<Protobuf Include="..\Shared\messages.proto" GrpcServices="Client" Link="Protos\messages.proto" />
@@ -45,7 +38,7 @@
4538
<ProjectReference Include="..\..\..\src\Grpc.AspNetCore.Web\Grpc.AspNetCore.Web.csproj" />
4639
</ItemGroup>
4740

48-
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
41+
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
4942
<ProjectReference Include="..\..\..\src\Grpc.Net.Client\Grpc.Net.Client.csproj" />
5043

5144
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />

perf/benchmarkapps/GrpcClient/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ private static ChannelBase CreateChannel(string target)
419419
clientCertificate
420420
};
421421
}
422-
#if NET5_0
422+
#if NET5_0 || NET6_0
423423
if (!string.IsNullOrEmpty(_options.UdsFileName))
424424
{
425425
var connectionFactory = new UnixDomainSocketConnectionFactory(new UnixDomainSocketEndPoint(ResolveUdsPath(_options.UdsFileName)));
@@ -432,7 +432,7 @@ private static ChannelBase CreateChannel(string target)
432432

433433
return GrpcChannel.ForAddress(address, new GrpcChannelOptions
434434
{
435-
#if NET5_0
435+
#if NET5_0 || NET6_0
436436
HttpHandler = httpClientHandler,
437437
#else
438438
HttpClient = new HttpClient(httpClientHandler),

perf/benchmarkapps/GrpcClient/UnixDomainSocketConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
using System.Threading;
2424
using System.Threading.Tasks;
2525

26-
#if NET5_0
26+
#if NET5_0 || NET6_0
2727

2828
namespace GrpcClient
2929
{

perf/benchmarkapps/GrpcCoreServer/GrpcCoreServer.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
<TargetFramework Condition="'$(BenchmarksTargetFramework)' != ''">$(BenchmarksTargetFramework)</TargetFramework>
65
<OutputType>Exe</OutputType>
76
</PropertyGroup>
87

9-
<!-- Allow benchmarks to specify the latest framework -->
10-
<ItemGroup Condition="'$(BenchmarksTargetFramework)' != ''">
11-
<FrameworkReference Update="Microsoft.AspNetCore.App" RuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppPackageVersion)" />
12-
<FrameworkReference Update="Microsoft.NETCore.App" RuntimeFrameworkVersion="$(MicrosoftNETCoreAppPackageVersion)" />
13-
</ItemGroup>
14-
158
<ItemGroup>
169
<Protobuf Include="..\Shared\benchmark_service.proto" GrpcServices="Server" Link="Protos\benchmark_service.proto" />
1710
<Protobuf Include="..\Shared\messages.proto" GrpcServices="Server" Link="Protos\messages.proto" />

0 commit comments

Comments
 (0)