diff --git a/MetaPackages.sln b/MetaPackages.sln index cb1e84eea6..3a53e49bdd 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26923.0 +VisualStudioVersion = 15.0.27005.2 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" ProjectSection(SolutionItems) = preProject @@ -30,9 +30,6 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" - ProjectSection(SolutionItems) = preProject - test\Directory.Build.props = test\Directory.Build.props - EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.FunctionalTests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" EndProject @@ -52,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "t EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateDefaultBuilderOfTApp", "test\TestSites\CreateDefaultBuilderOfTApp\CreateDefaultBuilderOfTApp.csproj", "{A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Tests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.Tests.csproj", "{BD08F027-3BB9-427B-9367-19534B7376B3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -102,6 +101,10 @@ Global {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.Build.0 = Release|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -120,6 +123,7 @@ Global {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {BD08F027-3BB9-427B-9367-19534B7376B3} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A666E9B0-125B-4975-B35B-09A6D68A5047} diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs index 9e3da42b41..b5eb900273 100644 --- a/samples/SampleApp/Program.cs +++ b/samples/SampleApp/Program.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 8af02eb9ea..df3b91d75b 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -185,6 +185,11 @@ namespace Microsoft.AspNetCore options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); }); + if (args != null) + { + builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build()); + } + return builder; } @@ -206,10 +211,7 @@ namespace Microsoft.AspNetCore /// The type containing the startup methods for the application. /// The command line args. /// The initialized . - public static IWebHostBuilder CreateDefaultBuilder(string[] args) where TStartup : class - { - return CreateDefaultBuilder(args) - .UseStartup(); - } + public static IWebHostBuilder CreateDefaultBuilder(string[] args) where TStartup : class => + CreateDefaultBuilder(args).UseStartup(); } } diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj new file mode 100644 index 0000000000..7da44ee745 --- /dev/null +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp2.0;net461 + netcoreapp2.0 + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs new file mode 100644 index 0000000000..27f98263f5 --- /dev/null +++ b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs @@ -0,0 +1,18 @@ +// 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 Microsoft.AspNetCore.Hosting; +using Xunit; + +namespace Microsoft.AspNetCore.Tests +{ + public class WebHostTests + { + [Fact] + public void WebHostConfiguration_IncludesCommandLineArguments() + { + var builder = WebHost.CreateDefaultBuilder(new string[] { "--urls", "http://localhost:5001" }); + Assert.Equal("http://localhost:5001", builder.GetSetting(WebHostDefaults.ServerUrlsKey)); + } + } +}