Remove UseServer(string) overload
- Removed the overload that takes a string because it's broken #731
This commit is contained in:
parent
bdc3959938
commit
c5e8120e39
|
|
@ -29,7 +29,7 @@ namespace SampleStartups
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
_host = new WebHostBuilder()
|
_host = new WebHostBuilder()
|
||||||
.UseServer("Microsoft.AspNetCore.Server.Kestrel")
|
//.UseKestrel()
|
||||||
.UseStartup<StartupExternallyControlled>()
|
.UseStartup<StartupExternallyControlled>()
|
||||||
.Start(_urls.ToArray());
|
.Start(_urls.ToArray());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace SampleStartups
|
||||||
|
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
.UseConfiguration(config) // Default set of configurations to use, may be subsequently overridden
|
.UseConfiguration(config) // Default set of configurations to use, may be subsequently overridden
|
||||||
.UseServer("Microsoft.AspNetCore.Server.Kestrel") // Set the server manually
|
//.UseKestrel()
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory()) // Override the content root with the current directory
|
.UseContentRoot(Directory.GetCurrentDirectory()) // Override the content root with the current directory
|
||||||
.UseUrls("http://*:1000", "https://*:902")
|
.UseUrls("http://*:1000", "https://*:902")
|
||||||
.UseEnvironment("Development")
|
.UseEnvironment("Development")
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace SampleStartups
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
.UseServer("Microsoft.AspNetCore.Server.Kestrel")
|
//.UseKestrel()
|
||||||
.UseStartup<StartupHelloWorld>()
|
.UseStartup<StartupHelloWorld>()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
public static readonly string DetailedErrorsKey = "detailedErrors";
|
public static readonly string DetailedErrorsKey = "detailedErrors";
|
||||||
public static readonly string EnvironmentKey = "environment";
|
public static readonly string EnvironmentKey = "environment";
|
||||||
public static readonly string ServerKey = "server";
|
|
||||||
public static readonly string WebRootKey = "webroot";
|
public static readonly string WebRootKey = "webroot";
|
||||||
public static readonly string CaptureStartupErrorsKey = "captureStartupErrors";
|
public static readonly string CaptureStartupErrorsKey = "captureStartupErrors";
|
||||||
public static readonly string ServerUrlsKey = "server.urls";
|
public static readonly string ServerUrlsKey = "server.urls";
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
DetailedErrors = ParseBool(configuration, WebHostDefaults.DetailedErrorsKey);
|
DetailedErrors = ParseBool(configuration, WebHostDefaults.DetailedErrorsKey);
|
||||||
CaptureStartupErrors = ParseBool(configuration, WebHostDefaults.CaptureStartupErrorsKey);
|
CaptureStartupErrors = ParseBool(configuration, WebHostDefaults.CaptureStartupErrorsKey);
|
||||||
Environment = configuration[WebHostDefaults.EnvironmentKey];
|
Environment = configuration[WebHostDefaults.EnvironmentKey];
|
||||||
ServerAssembly = configuration[WebHostDefaults.ServerKey];
|
|
||||||
WebRoot = configuration[WebHostDefaults.WebRootKey];
|
WebRoot = configuration[WebHostDefaults.WebRootKey];
|
||||||
ContentRootPath = configuration[WebHostDefaults.ContentRootKey];
|
ContentRootPath = configuration[WebHostDefaults.ContentRootKey];
|
||||||
}
|
}
|
||||||
|
|
@ -37,8 +36,6 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
|
|
||||||
public string Environment { get; set; }
|
public string Environment { get; set; }
|
||||||
|
|
||||||
public string ServerAssembly { get; set; }
|
|
||||||
|
|
||||||
public string StartupAssembly { get; set; }
|
public string StartupAssembly { get; set; }
|
||||||
|
|
||||||
public string WebRoot { get; set; }
|
public string WebRoot { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -187,25 +187,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
// Ensure object pooling is available everywhere.
|
// Ensure object pooling is available everywhere.
|
||||||
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(_options.ServerAssembly))
|
|
||||||
{
|
|
||||||
// Add the server
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var serverType = ServerLoader.ResolveServerType(_options.ServerAssembly);
|
|
||||||
services.AddSingleton(typeof(IServer), serverType);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
var capture = ExceptionDispatchInfo.Capture(ex);
|
|
||||||
services.AddSingleton<IServer>(_ =>
|
|
||||||
{
|
|
||||||
capture.Throw();
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(_options.StartupAssembly))
|
if (!string.IsNullOrEmpty(_options.StartupAssembly))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -125,22 +125,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseSetting(WebHostDefaults.StartupAssemblyKey, startupAssemblyName);
|
.UseSetting(WebHostDefaults.StartupAssemblyKey, startupAssemblyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Specify the assembly containing the server to be used by the web host.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hostBuilder">The <see cref="IWebHostBuilder"/> to configure.</param>
|
|
||||||
/// <param name="assemblyName">The name of the assembly containing the server to be used.</param>
|
|
||||||
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
|
|
||||||
public static IWebHostBuilder UseServer(this IWebHostBuilder hostBuilder, string assemblyName)
|
|
||||||
{
|
|
||||||
if (assemblyName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(assemblyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return hostBuilder.UseSetting(WebHostDefaults.ServerKey, assemblyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify the server to be used by the web host.
|
/// Specify the server to be used by the web host.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
var parameters = new Dictionary<string, string>()
|
var parameters = new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{ "webroot", "wwwroot"},
|
{ "webroot", "wwwroot"},
|
||||||
{ "server", "Microsoft.AspNetCore.Server.Kestrel"},
|
|
||||||
{ "applicationName", "MyProjectReference"},
|
{ "applicationName", "MyProjectReference"},
|
||||||
{ "startupAssembly", "MyProjectReference" },
|
{ "startupAssembly", "MyProjectReference" },
|
||||||
{ "environment", "Development"},
|
{ "environment", "Development"},
|
||||||
|
|
@ -27,7 +26,6 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());
|
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());
|
||||||
|
|
||||||
Assert.Equal("wwwroot", config.WebRoot);
|
Assert.Equal("wwwroot", config.WebRoot);
|
||||||
Assert.Equal("Microsoft.AspNetCore.Server.Kestrel", config.ServerAssembly);
|
|
||||||
Assert.Equal("MyProjectReference", config.ApplicationName);
|
Assert.Equal("MyProjectReference", config.ApplicationName);
|
||||||
Assert.Equal("MyProjectReference", config.StartupAssembly);
|
Assert.Equal("MyProjectReference", config.StartupAssembly);
|
||||||
Assert.Equal("Development", config.Environment);
|
Assert.Equal("Development", config.Environment);
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,12 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
var vals = new Dictionary<string, string>
|
var vals = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "server", "Microsoft.AspNetCore.Hosting.Tests" }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddInMemoryCollection(vals);
|
.AddInMemoryCollection(vals);
|
||||||
var config = builder.Build();
|
var config = builder.Build();
|
||||||
var host = CreateBuilder(config).Build();
|
var host = CreateBuilder(config).UseServer(this).Build();
|
||||||
host.Start();
|
host.Start();
|
||||||
Assert.NotNull(host.Services.GetService<IHostingEnvironment>());
|
Assert.NotNull(host.Services.GetService<IHostingEnvironment>());
|
||||||
}
|
}
|
||||||
|
|
@ -87,13 +86,12 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
var vals = new Dictionary<string, string>
|
var vals = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "Server", "Microsoft.AspNetCore.Hosting.Tests" }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddInMemoryCollection(vals);
|
.AddInMemoryCollection(vals);
|
||||||
var config = builder.Build();
|
var config = builder.Build();
|
||||||
var host = CreateBuilder(config).Build();
|
var host = CreateBuilder(config).UseServer(this).Build();
|
||||||
host.Start();
|
host.Start();
|
||||||
Assert.NotNull(host.Services.GetService<IHostingEnvironment>());
|
Assert.NotNull(host.Services.GetService<IHostingEnvironment>());
|
||||||
}
|
}
|
||||||
|
|
@ -103,13 +101,12 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
var vals = new Dictionary<string, string>
|
var vals = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "Server", "Microsoft.AspNetCore.Hosting.Tests" }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddInMemoryCollection(vals);
|
.AddInMemoryCollection(vals);
|
||||||
var config = builder.Build();
|
var config = builder.Build();
|
||||||
var host = CreateBuilder(config).Build();
|
var host = CreateBuilder(config).UseServer(this).Build();
|
||||||
host.Start();
|
host.Start();
|
||||||
Assert.NotNull(host.Services.GetService<IHostingEnvironment>());
|
Assert.NotNull(host.Services.GetService<IHostingEnvironment>());
|
||||||
Assert.Equal("http://localhost:5000", host.ServerFeatures.Get<IServerAddressesFeature>().Addresses.First());
|
Assert.Equal("http://localhost:5000", host.ServerFeatures.Get<IServerAddressesFeature>().Addresses.First());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue