Skip to content

Commit c2a4b30

Browse files
committed
Reacting to hosting changes
1 parent d65e6f9 commit c2a4b30

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/Benchmarks/Middleware/DebugInfoPageMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task Invoke(HttpContext httpContext)
5151
await httpContext.Response.WriteAsync($"<li>Framework: {_appEnv.RuntimeFramework.FullName}</li>");
5252
await httpContext.Response.WriteAsync($"<li>Server GC enabled: {GCSettings.IsServerGC}</li>");
5353
await httpContext.Response.WriteAsync($"<li>Configuration: {_configurationName}</li>");
54-
await httpContext.Response.WriteAsync($"<li>Server: {_hostingEnv.Configuration["server"]}</li>");
54+
await httpContext.Response.WriteAsync($"<li>Server: {Program.Server}</li>");
5555
await httpContext.Response.WriteAsync($"<li>Server URLs: {string.Join(", ", _serverAddresses.Addresses)}</li>");
5656
await httpContext.Response.WriteAsync($"<li>Supports Send File: {httpContext.Features.Get<IHttpSendFileFeature>() != null}</li>");
5757

src/Benchmarks/Program.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Benchmarks
1414
public class Program
1515
{
1616
public static string[] Args;
17+
public static string Server;
1718

1819
public static void Main(string[] args)
1920
{
@@ -25,18 +26,21 @@ public static void Main(string[] args)
2526

2627
Console.WriteLine($"Current directory: {Directory.GetCurrentDirectory()}");
2728

28-
var webHost = new WebHostBuilder()
29+
var webHostBuilder = new WebHostBuilder()
2930
.UseServer("Microsoft.AspNetCore.Server.Kestrel")
3031
.UseCaptureStartupErrors(false)
31-
.UseApplicationBasePath(Directory.GetCurrentDirectory())
32+
.UseContentRoot(Directory.GetCurrentDirectory())
3233
.UseDefaultConfiguration(args)
3334
.UseStartup<Startup>()
3435
.ConfigureServices(services => services
3536
.AddSingleton(new ConsoleArgs(args))
3637
.AddSingleton<IScenariosConfiguration, ConsoleHostScenariosConfiguration>()
3738
.AddSingleton<Scenarios>()
38-
)
39-
.Build();
39+
);
40+
41+
Server = webHostBuilder.GetSetting(WebHostDefaults.ServerKey);
42+
43+
var webHost = webHostBuilder.Build();
4044

4145
StartInteractiveConsoleThread();
4246

src/Benchmarks/Startup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Benchmarks.Middleware;
1111
using Microsoft.AspNetCore.Builder;
1212
using Microsoft.AspNetCore.Hosting;
13-
using Microsoft.EntityFrameworkCore;
1413
using Microsoft.Extensions.Configuration;
1514
using Microsoft.Extensions.DependencyInjection;
1615
using Microsoft.Extensions.PlatformAbstractions;
@@ -24,7 +23,7 @@ public Startup(IApplicationEnvironment appEnv, IHostingEnvironment hostingEnv, S
2423
// Set up configuration sources.
2524
var builder = new ConfigurationBuilder()
2625
.SetBasePath(appEnv.ApplicationBasePath)
27-
.Include(hostingEnv.Configuration)
26+
.AddCommandLine(Program.Args)
2827
.AddJsonFile("appsettings.json")
2928
.AddJsonFile($"appsettings.{hostingEnv.EnvironmentName}.json", optional: true)
3029
.AddEnvironmentVariables();

src/Benchmarks/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"net451": {}
3030
},
31+
"content": [ "appsettings.json" ],
3132
"publishExclude": [
3233
"node_modules",
3334
"bower_components",

0 commit comments

Comments
 (0)