#1075 Suppress exceptions from failing to load HostingStartup assemblies

This commit is contained in:
Chris R 2017-05-22 15:47:53 -07:00
parent 68d1d4ce12
commit 7ac6842d18
2 changed files with 5 additions and 10 deletions

View File

@ -285,12 +285,6 @@ namespace Microsoft.AspNetCore.Hosting
if (exceptions.Count > 0) if (exceptions.Count > 0)
{ {
hostingStartupErrors = new AggregateException(exceptions); hostingStartupErrors = new AggregateException(exceptions);
// Throw directly if we're not capturing startup errors
if (!_options.CaptureStartupErrors)
{
throw hostingStartupErrors;
}
} }
} }

View File

@ -975,7 +975,7 @@ namespace Microsoft.AspNetCore.Hosting
} }
[Fact] [Fact]
public void Build_ThrowsIfUnloadableAssemblyNameInHostingStartupAssemblies() public void Build_DoesntThrowIfUnloadableAssemblyNameInHostingStartupAssemblies()
{ {
var builder = CreateWebHostBuilder() var builder = CreateWebHostBuilder()
.CaptureStartupErrors(false) .CaptureStartupErrors(false)
@ -983,9 +983,10 @@ namespace Microsoft.AspNetCore.Hosting
.Configure(app => { }) .Configure(app => { })
.UseServer(new TestServer()); .UseServer(new TestServer());
var ex = Assert.Throws<AggregateException>(() => builder.Build()); using (builder.Build())
Assert.IsType<InvalidOperationException>(ex.InnerExceptions[0]); {
Assert.IsType<FileNotFoundException>(ex.InnerExceptions[0].InnerException); Assert.Equal("0", builder.GetSetting("testhostingstartup"));
}
} }
[Fact] [Fact]