diff --git a/samples/MonoSanity/Program.cs b/samples/MonoSanity/Program.cs index c445914645..79ccae3327 100644 --- a/samples/MonoSanity/Program.cs +++ b/samples/MonoSanity/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; namespace MonoSanity { @@ -15,6 +16,9 @@ namespace MonoSanity public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) + .UseConfiguration(new ConfigurationBuilder() + .AddCommandLine(args) + .Build()) .UseStartup() .Build(); } diff --git a/src/Microsoft.Blazor.DevHost/Server/Program.cs b/src/Microsoft.Blazor.DevHost/Server/Program.cs index 163f07b6fe..5b5de413db 100644 --- a/src/Microsoft.Blazor.DevHost/Server/Program.cs +++ b/src/Microsoft.Blazor.DevHost/Server/Program.cs @@ -9,16 +9,12 @@ namespace Microsoft.Blazor.DevHost.Server { internal class Program { - internal static IWebHost BuildWebHost(string[] args) - { - var configuration = new ConfigurationBuilder() - .AddCommandLine(args) - .Build(); - - return WebHost.CreateDefaultBuilder(args) - .UseConfiguration(configuration) + internal static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseConfiguration(new ConfigurationBuilder() + .AddCommandLine(args) + .Build()) .UseStartup() .Build(); - } } } diff --git a/test/Microsoft.Blazor.E2ETest/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs b/test/Microsoft.Blazor.E2ETest/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs index ae9bcd73b6..295cb5a6e3 100644 --- a/test/Microsoft.Blazor.E2ETest/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs +++ b/test/Microsoft.Blazor.E2ETest/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs @@ -1,27 +1,36 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.IO; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures { - public class AspNetSiteServerFixture : WebHostServerFixture - where TStartup: class + public class AspNetSiteServerFixture : WebHostServerFixture { + public delegate IWebHost BuildWebHost(string[] args); + + public BuildWebHost BuildWebHostMethod { get; set; } + protected override IWebHost CreateWebHost() { - var sampleSitePath = Path.Combine( - FindSolutionDir(), - "samples", - typeof(TStartup).Assembly.GetName().Name); + if (BuildWebHostMethod == null) + { + throw new InvalidOperationException( + $"No value was provided for {nameof(BuildWebHostMethod)}"); + } - return WebHost.CreateDefaultBuilder() - .UseStartup() - .UseContentRoot(sampleSitePath) - .UseUrls("http://127.0.0.1:0") - .Build(); + var sampleSitePath = Path.Combine( + FindSolutionDir(), + "samples", + BuildWebHostMethod.Method.DeclaringType.Assembly.GetName().Name); + + return BuildWebHostMethod(new[] + { + "--urls", "http://127.0.0.1:0", + "--contentroot", sampleSitePath + }); } } } diff --git a/test/Microsoft.Blazor.E2ETest/Tests/MonoSanityTest.cs b/test/Microsoft.Blazor.E2ETest/Tests/MonoSanityTest.cs index f2f53c0418..49d2a04e0b 100644 --- a/test/Microsoft.Blazor.E2ETest/Tests/MonoSanityTest.cs +++ b/test/Microsoft.Blazor.E2ETest/Tests/MonoSanityTest.cs @@ -8,11 +8,12 @@ using Xunit; namespace Microsoft.Blazor.E2ETest.Tests { - public class MonoSanityTest : ServerTestBase> + public class MonoSanityTest : ServerTestBase { - public MonoSanityTest(BrowserFixture browserFixture, AspNetSiteServerFixture serverFixture) + public MonoSanityTest(BrowserFixture browserFixture, AspNetSiteServerFixture serverFixture) : base(browserFixture, serverFixture) { + serverFixture.BuildWebHostMethod = MonoSanity.Program.BuildWebHost; } [Fact]