Merge remote-tracking branch 'MetaPackages/rybrande/release22ToSrc' into rybrande/Mondo2.2
This commit is contained in:
commit
5e36c334e1
|
|
@ -0,0 +1,37 @@
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]in/
|
||||||
|
TestResults/
|
||||||
|
.nuget/
|
||||||
|
_ReSharper.*/
|
||||||
|
packages/
|
||||||
|
artifacts/
|
||||||
|
PublishProfiles/
|
||||||
|
*.user
|
||||||
|
*.suo
|
||||||
|
*.cache
|
||||||
|
*.docstates
|
||||||
|
_ReSharper.*
|
||||||
|
nuget.exe
|
||||||
|
*net45.csproj
|
||||||
|
*net451.csproj
|
||||||
|
*k10.csproj
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.pidb
|
||||||
|
*.userprefs
|
||||||
|
*DS_Store
|
||||||
|
*.ncrunchsolution
|
||||||
|
*.*sdf
|
||||||
|
*.ipch
|
||||||
|
*.sln.ide
|
||||||
|
project.lock.json
|
||||||
|
.vs
|
||||||
|
.vscode/
|
||||||
|
.build/
|
||||||
|
.testPublish/
|
||||||
|
global.json
|
||||||
|
|
||||||
|
# Dependencies from pre-requisite builds
|
||||||
|
.deps/
|
||||||
|
.rw/
|
||||||
|
.ro/
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<Project>
|
||||||
|
<Import
|
||||||
|
Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), AspNetCoreSettings.props))\AspNetCoreSettings.props"
|
||||||
|
Condition=" '$(CI)' != 'true' AND '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), AspNetCoreSettings.props))' != '' " />
|
||||||
|
|
||||||
|
<Import Project="version.props" />
|
||||||
|
<Import Project="build\dependencies.props" />
|
||||||
|
<Import Project="build\sources.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Product>Microsoft ASP.NET Core</Product>
|
||||||
|
<RepositoryUrl>https://github.com/aspnet/MetaPackages</RepositoryUrl>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
|
||||||
|
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
|
||||||
|
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)build\Key.snk</AssemblyOriginatorKeyFile>
|
||||||
|
<SignAssembly>true</SignAssembly>
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(MicrosoftNETCoreApp20PackageVersion)</RuntimeFrameworkVersion>
|
||||||
|
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">$(MicrosoftNETCoreApp21PackageVersion)</RuntimeFrameworkVersion>
|
||||||
|
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.2' ">$(MicrosoftNETCoreApp22PackageVersion)</RuntimeFrameworkVersion>
|
||||||
|
<NETStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">$(NETStandardLibrary20PackageVersion)</NETStandardImplicitPackageVersion>
|
||||||
|
<!-- aspnet/BuildTools#662 Don't police what version of NetCoreApp we use -->
|
||||||
|
<NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
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
|
||||||
|
src\Directory.Build.props = src\Directory.Build.props
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
Directory.Build.props = Directory.Build.props
|
||||||
|
Directory.Build.targets = Directory.Build.targets
|
||||||
|
NuGet.config = NuGet.config
|
||||||
|
version.xml = version.xml
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1-C38E-408C-A7EC-A5C040D041E1}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
build\dependencies.props = build\dependencies.props
|
||||||
|
build\repo.targets = build\repo.targets
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}"
|
||||||
|
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}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.FunctionalTests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestSites", "TestSites", "{EC22261D-0DE1-47DE-8F7C-072675D6F5B4}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRouteBuilderUrlApp", "test\TestSites\StartRouteBuilderUrlApp\StartRouteBuilderUrlApp.csproj", "{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartWithIApplicationBuilderUrlApp", "test\TestSites\StartWithIApplicationBuilderUrlApp\StartWithIApplicationBuilderUrlApp.csproj", "{3A85FA52-F601-422E-A42E-9F187DB28492}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp", "test\TestSites\StartRequestDelegateUrlApp\StartRequestDelegateUrlApp.csproj", "{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}"
|
||||||
|
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
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3A85FA52-F601-422E-A42E-9F187DB28492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3A85FA52-F601-422E-A42E-9F187DB28492}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3A85FA52-F601-422E-A42E-9F187DB28492}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3A85FA52-F601-422E-A42E-9F187DB28492}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{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
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}
|
||||||
|
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274}
|
||||||
|
{C72A756A-D29D-44C7-83D4-821DBE82DBCA} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}
|
||||||
|
{EC22261D-0DE1-47DE-8F7C-072675D6F5B4} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}
|
||||||
|
{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4}
|
||||||
|
{3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4}
|
||||||
|
{401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4}
|
||||||
|
{79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4}
|
||||||
|
{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}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"Default": {
|
||||||
|
"rules": [
|
||||||
|
"DefaultCompositeRule"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
Meta packages
|
||||||
|
========
|
||||||
|
|
||||||
|
This repo contains NuGet meta packages that help quickly reference sets of common packages.
|
||||||
|
|
||||||
|
This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo.
|
||||||
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,41 @@
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Label="Package Versions">
|
||||||
|
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview2-20181004.6</InternalAspNetCoreSdkPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
|
||||||
|
<MicrosoftAspNetCoreAspNetCoreModuleV2PackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreAspNetCoreModuleV2PackageVersion>
|
||||||
|
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreHostFilteringPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreHostFilteringPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreHostingPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreHostingPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreRoutingPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreRoutingPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreServerIISPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreServerIISPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreServerIntegrationTestingIISPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreServerIntegrationTestingIISPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.6.0-preview3-35425</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreServerKestrelHttpsPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreServerKestrelHttpsPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||||
|
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.2.0-preview3-35425</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||||
|
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
|
||||||
|
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
|
||||||
|
<MicrosoftExtensionsConfigurationFileExtensionsPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsConfigurationFileExtensionsPackageVersion>
|
||||||
|
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||||
|
<MicrosoftExtensionsConfigurationUserSecretsPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsConfigurationUserSecretsPackageVersion>
|
||||||
|
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsLoggingConfigurationPackageVersion>
|
||||||
|
<MicrosoftExtensionsLoggingConsolePackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||||
|
<MicrosoftExtensionsLoggingDebugPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||||
|
<MicrosoftExtensionsLoggingEventSourcePackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsLoggingEventSourcePackageVersion>
|
||||||
|
<MicrosoftExtensionsLoggingPackageVersion>2.2.0-preview3-35425</MicrosoftExtensionsLoggingPackageVersion>
|
||||||
|
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
|
||||||
|
<MicrosoftNETCoreApp21PackageVersion>2.1.3</MicrosoftNETCoreApp21PackageVersion>
|
||||||
|
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview3-27001-02</MicrosoftNETCoreApp22PackageVersion>
|
||||||
|
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
||||||
|
<MoqPackageVersion>4.7.49</MoqPackageVersion>
|
||||||
|
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
||||||
|
<XunitPackageVersion>2.3.1</XunitPackageVersion>
|
||||||
|
<XunitRunnerVisualStudioPackageVersion>2.4.0</XunitRunnerVisualStudioPackageVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
|
||||||
|
<PropertyGroup Label="Package Versions: Pinned" />
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<Project>
|
||||||
|
<Import Project="dependencies.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- These properties are use by the automation that updates dependencies.props -->
|
||||||
|
<LineupPackageId>Internal.AspNetCore.Universe.Lineup</LineupPackageId>
|
||||||
|
<LineupPackageVersion>2.2.0-*</LineupPackageVersion>
|
||||||
|
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json</LineupPackageRestoreSource>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp20PackageVersion)" />
|
||||||
|
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp21PackageVersion)" />
|
||||||
|
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp22PackageVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project>
|
||||||
|
<Import Project="$(DotNetRestoreSourcePropsPath)" Condition="'$(DotNetRestoreSourcePropsPath)' != ''"/>
|
||||||
|
|
||||||
|
<PropertyGroup Label="RestoreSources">
|
||||||
|
<RestoreSources>$(DotNetRestoreSources)</RestoreSources>
|
||||||
|
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true' AND '$(AspNetUniverseBuildOffline)' != 'true' ">
|
||||||
|
$(RestoreSources);
|
||||||
|
https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
|
||||||
|
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
|
||||||
|
https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json;
|
||||||
|
</RestoreSources>
|
||||||
|
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
|
||||||
|
$(RestoreSources);
|
||||||
|
https://api.nuget.org/v3/index.json;
|
||||||
|
</RestoreSources>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
// 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 Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
|
||||||
|
namespace SampleApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
HelloWorld();
|
||||||
|
|
||||||
|
CustomUrl();
|
||||||
|
|
||||||
|
CustomRouter();
|
||||||
|
|
||||||
|
CustomApplicationBuilder();
|
||||||
|
|
||||||
|
StartupClass(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HelloWorld()
|
||||||
|
{
|
||||||
|
using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!")))
|
||||||
|
{
|
||||||
|
//host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022
|
||||||
|
Console.WriteLine("Running HelloWorld: Press any key to shutdown and start the next sample...");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CustomUrl()
|
||||||
|
{
|
||||||
|
// Changing the listening URL
|
||||||
|
using (WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!")))
|
||||||
|
{
|
||||||
|
//host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022
|
||||||
|
Console.WriteLine("Running CustomUrl: Press any key to shutdown and start the next sample...");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CustomRouter()
|
||||||
|
{
|
||||||
|
// Using a router
|
||||||
|
using (WebHost.Start(router => router
|
||||||
|
.MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}"))
|
||||||
|
.MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}"))
|
||||||
|
.MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!"))
|
||||||
|
.MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}"))
|
||||||
|
.MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!"))))
|
||||||
|
{
|
||||||
|
//host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022
|
||||||
|
Console.WriteLine("Running CustomRouter: Press any key to shutdown and start the next sample...");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CustomApplicationBuilder()
|
||||||
|
{
|
||||||
|
// Using a application builder
|
||||||
|
using (WebHost.StartWith(app =>
|
||||||
|
{
|
||||||
|
app.UseStaticFiles();
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("Hello, World!");
|
||||||
|
});
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
//host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022
|
||||||
|
Console.WriteLine("Running CustomApplicationBuilder: Press any key to shutdown and start the next sample...");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void StartupClass(string[] args)
|
||||||
|
{
|
||||||
|
// Using defaults with a Startup class
|
||||||
|
using (var host = WebHost.CreateDefaultBuilder(args)
|
||||||
|
.UseStartup<Startup>()
|
||||||
|
.Build())
|
||||||
|
{
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:53432/",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SampleApp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "http://localhost:53433"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp2.2;net461</TargetFrameworks>
|
||||||
|
<UserSecretsId>aspnetcore-MetaPackagesSampleApp-20170406180413</UserSecretsId>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="wwwroot\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(MicrosoftAspNetCoreStaticFilesPackageVersion)" />
|
||||||
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// 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.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace SampleApp
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||||
|
{
|
||||||
|
app.Run(async (context) =>
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync($"Hello from {nameof(Startup)}!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
{
|
||||||
|
"AllowedHosts": "example.com;localhost",
|
||||||
|
"Kestrel": {
|
||||||
|
"EndPoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://localhost:5005"
|
||||||
|
}
|
||||||
|
|
||||||
|
// To enable HTTPS using a certificate file, set the path to a .pfx file in
|
||||||
|
// the "Path" property below and configure the password in user secrets.
|
||||||
|
// The "Password" property should be set in user secrets.
|
||||||
|
//"HttpsInlineCertFile": {
|
||||||
|
// "Url": "http://localhost:5005"
|
||||||
|
// "Certificate": {
|
||||||
|
// "Path": "<path to .pfx file>",
|
||||||
|
// "Password: "<cert password>"
|
||||||
|
// }
|
||||||
|
//},
|
||||||
|
|
||||||
|
//"HttpsInlineCertStore": {
|
||||||
|
// "Url": "http://localhost:5005"
|
||||||
|
// "Certificate": {
|
||||||
|
// "Subject": "",
|
||||||
|
// "Store": "",
|
||||||
|
// "Location": "",
|
||||||
|
// "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired)
|
||||||
|
// }
|
||||||
|
//},
|
||||||
|
|
||||||
|
// This uses the cert defined under Certificates/Default or the development cert.
|
||||||
|
//"HttpsDefaultCert": {
|
||||||
|
// "Url": "http://localhost:5005"
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Certificates": {
|
||||||
|
//"Default": {
|
||||||
|
// "Path": "<file>",
|
||||||
|
// "Password": "<password>"
|
||||||
|
//},
|
||||||
|
|
||||||
|
// From cert store:
|
||||||
|
//"Default": {
|
||||||
|
// "Subject": "",
|
||||||
|
// "Store": "",
|
||||||
|
// "Location": "",
|
||||||
|
// "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired certificates)
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
A static HTML file.
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<Project>
|
||||||
|
<Import Project="..\Directory.Build.props" />
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkPackageVersion)" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
// 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 Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore
|
||||||
|
{
|
||||||
|
internal class HostFilteringStartupFilter : IStartupFilter
|
||||||
|
{
|
||||||
|
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
|
||||||
|
{
|
||||||
|
return app =>
|
||||||
|
{
|
||||||
|
app.UseHostFiltering();
|
||||||
|
next(app);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||||
|
<PackageTags>aspnetcore</PackageTags>
|
||||||
|
<Description>Microsoft.AspNetCore</Description>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<EnableApiCheck>false</EnableApiCheck>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="$(MicrosoftAspNetCoreDiagnosticsPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.HostFiltering" Version="$(MicrosoftAspNetCoreHostFilteringPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="$(MicrosoftAspNetCoreHostingPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="$(MicrosoftAspNetCoreRoutingPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="$(MicrosoftAspNetCoreServerIISPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(MicrosoftAspNetCoreServerIISIntegrationPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="$(MicrosoftAspNetCoreServerKestrelHttpsPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsConfigurationFileExtensionsPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsConfigurationJsonPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(MicrosoftExtensionsConfigurationCommandLinePackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="$(MicrosoftExtensionsConfigurationUserSecretsPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="$(MicrosoftExtensionsLoggingConfigurationPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsLoggingDebugPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="$(MicrosoftExtensionsLoggingEventSourcePackageVersion)" PrivateAssets="None" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,244 @@
|
||||||
|
// 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 System.Reflection;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.HostFiltering;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides convenience methods for creating instances of <see cref="IWebHost"/> and <see cref="IWebHostBuilder"/> with pre-configured defaults.
|
||||||
|
/// </summary>
|
||||||
|
public static class WebHost
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
|
||||||
|
/// See <see cref="CreateDefaultBuilder()"/> for details.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app">A delegate that handles requests to the application.</param>
|
||||||
|
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
|
||||||
|
public static IWebHost Start(RequestDelegate app) =>
|
||||||
|
Start(url: null, app: app);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
|
||||||
|
/// See <see cref="CreateDefaultBuilder()"/> for details.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">The URL the hosted application will listen on.</param>
|
||||||
|
/// <param name="app">A delegate that handles requests to the application.</param>
|
||||||
|
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
|
||||||
|
public static IWebHost Start(string url, RequestDelegate app)
|
||||||
|
{
|
||||||
|
var startupAssemblyName = app.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name;
|
||||||
|
return StartWith(url: url, configureServices: null, app: appBuilder => appBuilder.Run(app), applicationName: startupAssemblyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
|
||||||
|
/// See <see cref="CreateDefaultBuilder()"/> for details.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="routeBuilder">A delegate that configures the router for handling requests to the application.</param>
|
||||||
|
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
|
||||||
|
public static IWebHost Start(Action<IRouteBuilder> routeBuilder) =>
|
||||||
|
Start(url: null, routeBuilder: routeBuilder);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
|
||||||
|
/// See <see cref="CreateDefaultBuilder()"/> for details.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">The URL the hosted application will listen on.</param>
|
||||||
|
/// <param name="routeBuilder">A delegate that configures the router for handling requests to the application.</param>
|
||||||
|
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
|
||||||
|
public static IWebHost Start(string url, Action<IRouteBuilder> routeBuilder)
|
||||||
|
{
|
||||||
|
var startupAssemblyName = routeBuilder.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name;
|
||||||
|
return StartWith(url, services => services.AddRouting(), appBuilder => appBuilder.UseRouter(routeBuilder), applicationName: startupAssemblyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
|
||||||
|
/// See <see cref="CreateDefaultBuilder()"/> for details.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app">The delegate that configures the <see cref="IApplicationBuilder"/>.</param>
|
||||||
|
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
|
||||||
|
public static IWebHost StartWith(Action<IApplicationBuilder> app) =>
|
||||||
|
StartWith(url: null, app: app);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes and starts a new <see cref="IWebHost"/> with pre-configured defaults.
|
||||||
|
/// See <see cref="CreateDefaultBuilder()"/> for details.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">The URL the hosted application will listen on.</param>
|
||||||
|
/// <param name="app">The delegate that configures the <see cref="IApplicationBuilder"/>.</param>
|
||||||
|
/// <returns>A started <see cref="IWebHost"/> that hosts the application.</returns>
|
||||||
|
public static IWebHost StartWith(string url, Action<IApplicationBuilder> app) =>
|
||||||
|
StartWith(url: url, configureServices: null, app: app, applicationName: null);
|
||||||
|
|
||||||
|
private static IWebHost StartWith(string url, Action<IServiceCollection> configureServices, Action<IApplicationBuilder> app, string applicationName)
|
||||||
|
{
|
||||||
|
var builder = CreateDefaultBuilder();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
builder.UseUrls(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configureServices != null)
|
||||||
|
{
|
||||||
|
builder.ConfigureServices(configureServices);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Configure(app);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(applicationName))
|
||||||
|
{
|
||||||
|
builder.UseSetting(WebHostDefaults.ApplicationKey, applicationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
var host = builder.Build();
|
||||||
|
|
||||||
|
host.Start();
|
||||||
|
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebHostBuilder"/> class with pre-configured defaults.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||||
|
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
||||||
|
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
||||||
|
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostingEnvironment.EnvironmentName"/>].json',
|
||||||
|
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||||
|
/// load <see cref="IConfiguration"/> from environment variables,
|
||||||
|
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||||
|
/// and enable IIS integration.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>The initialized <see cref="IWebHostBuilder"/>.</returns>
|
||||||
|
public static IWebHostBuilder CreateDefaultBuilder() =>
|
||||||
|
CreateDefaultBuilder(args: null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebHostBuilder"/> class with pre-configured defaults.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||||
|
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
||||||
|
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
||||||
|
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostingEnvironment.EnvironmentName"/>].json',
|
||||||
|
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||||
|
/// load <see cref="IConfiguration"/> from environment variables,
|
||||||
|
/// load <see cref="IConfiguration"/> from supplied command line args,
|
||||||
|
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||||
|
/// and enable IIS integration.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="args">The command line args.</param>
|
||||||
|
/// <returns>The initialized <see cref="IWebHostBuilder"/>.</returns>
|
||||||
|
public static IWebHostBuilder CreateDefaultBuilder(string[] args)
|
||||||
|
{
|
||||||
|
var builder = new WebHostBuilder();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(builder.GetSetting(WebHostDefaults.ContentRootKey)))
|
||||||
|
{
|
||||||
|
builder.UseContentRoot(Directory.GetCurrentDirectory());
|
||||||
|
}
|
||||||
|
if (args != null)
|
||||||
|
{
|
||||||
|
builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.UseKestrel((builderContext, options) =>
|
||||||
|
{
|
||||||
|
options.Configure(builderContext.Configuration.GetSection("Kestrel"));
|
||||||
|
})
|
||||||
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||||
|
{
|
||||||
|
var env = hostingContext.HostingEnvironment;
|
||||||
|
|
||||||
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||||
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
||||||
|
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName));
|
||||||
|
if (appAssembly != null)
|
||||||
|
{
|
||||||
|
config.AddUserSecrets(appAssembly, optional: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.AddEnvironmentVariables();
|
||||||
|
|
||||||
|
if (args != null)
|
||||||
|
{
|
||||||
|
config.AddCommandLine(args);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ConfigureLogging((hostingContext, logging) =>
|
||||||
|
{
|
||||||
|
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
||||||
|
logging.AddConsole();
|
||||||
|
logging.AddDebug();
|
||||||
|
logging.AddEventSourceLogger();
|
||||||
|
})
|
||||||
|
.ConfigureServices((hostingContext, services) =>
|
||||||
|
{
|
||||||
|
// Fallback
|
||||||
|
services.PostConfigure<HostFilteringOptions>(options =>
|
||||||
|
{
|
||||||
|
if (options.AllowedHosts == null || options.AllowedHosts.Count == 0)
|
||||||
|
{
|
||||||
|
// "AllowedHosts": "localhost;127.0.0.1;[::1]"
|
||||||
|
var hosts = hostingContext.Configuration["AllowedHosts"]?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
// Fall back to "*" to disable.
|
||||||
|
options.AllowedHosts = (hosts?.Length > 0 ? hosts : new[] { "*" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Change notification
|
||||||
|
services.AddSingleton<IOptionsChangeTokenSource<HostFilteringOptions>>(
|
||||||
|
new ConfigurationChangeTokenSource<HostFilteringOptions>(hostingContext.Configuration));
|
||||||
|
|
||||||
|
services.AddTransient<IStartupFilter, HostFilteringStartupFilter>();
|
||||||
|
})
|
||||||
|
.UseIIS()
|
||||||
|
.UseIISIntegration()
|
||||||
|
.UseDefaultServiceProvider((context, options) =>
|
||||||
|
{
|
||||||
|
options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
|
||||||
|
});
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebHostBuilder"/> class with pre-configured defaults using typed Startup.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||||
|
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
||||||
|
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
||||||
|
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostingEnvironment.EnvironmentName"/>].json',
|
||||||
|
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||||
|
/// load <see cref="IConfiguration"/> from environment variables,
|
||||||
|
/// load <see cref="IConfiguration"/> from supplied command line args,
|
||||||
|
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||||
|
/// enable IIS integration.
|
||||||
|
/// </remarks>
|
||||||
|
/// <typeparam name ="TStartup">The type containing the startup methods for the application.</typeparam>
|
||||||
|
/// <param name="args">The command line args.</param>
|
||||||
|
/// <returns>The initialized <see cref="IWebHostBuilder"/>.</returns>
|
||||||
|
public static IWebHostBuilder CreateDefaultBuilder<TStartup>(string[] args) where TStartup : class =>
|
||||||
|
CreateDefaultBuilder(args).UseStartup<TStartup>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,136 @@
|
||||||
|
{
|
||||||
|
"AssemblyIdentity": "Microsoft.AspNetCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
|
"Types": [
|
||||||
|
{
|
||||||
|
"Name": "Microsoft.AspNetCore.WebHost",
|
||||||
|
"Visibility": "Public",
|
||||||
|
"Kind": "Class",
|
||||||
|
"Abstract": true,
|
||||||
|
"Static": true,
|
||||||
|
"Sealed": true,
|
||||||
|
"ImplementedInterfaces": [],
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "Start",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "app",
|
||||||
|
"Type": "Microsoft.AspNetCore.Http.RequestDelegate"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "Start",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "url",
|
||||||
|
"Type": "System.String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "app",
|
||||||
|
"Type": "Microsoft.AspNetCore.Http.RequestDelegate"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "Start",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "routeBuilder",
|
||||||
|
"Type": "System.Action<Microsoft.AspNetCore.Routing.IRouteBuilder>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "Start",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "url",
|
||||||
|
"Type": "System.String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "routeBuilder",
|
||||||
|
"Type": "System.Action<Microsoft.AspNetCore.Routing.IRouteBuilder>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "StartWith",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "app",
|
||||||
|
"Type": "System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "StartWith",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "url",
|
||||||
|
"Type": "System.String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "app",
|
||||||
|
"Type": "System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "CreateDefaultBuilder",
|
||||||
|
"Parameters": [],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHostBuilder",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "CreateDefaultBuilder",
|
||||||
|
"Parameters": [
|
||||||
|
{
|
||||||
|
"Name": "args",
|
||||||
|
"Type": "System.String[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReturnType": "Microsoft.AspNetCore.Hosting.IWebHostBuilder",
|
||||||
|
"Static": true,
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"GenericParameters": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<Project>
|
||||||
|
<Import Project="..\Directory.Build.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<DeveloperBuildTestTfms>netcoreapp2.2</DeveloperBuildTestTfms>
|
||||||
|
<StandardTestTfms>$(DeveloperBuildTestTfms)</StandardTestTfms>
|
||||||
|
|
||||||
|
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' AND '$(OS)' == 'Windows_NT' ">$(StandardTestTfms);net461</StandardTestTfms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkPackageVersion)" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Workaround for "Use executable flags in Microsoft.NET.Test.Sdk" (https://github.com/Microsoft/vstest/issues/792).
|
||||||
|
Remove when fixed.
|
||||||
|
-->
|
||||||
|
<HasRuntimeOutput>true</HasRuntimeOutput>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="testCert.pfx" CopyToOutputDirectory="PreserveNewest" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(MicrosoftAspNetCoreServerIntegrationTestingPackageVersion)" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting.IIS" Version="$(MicrosoftAspNetCoreServerIntegrationTestingIISPackageVersion)" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||||
|
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
|
||||||
|
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,256 @@
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Sdk;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Tests
|
||||||
|
{
|
||||||
|
public class WebHostFunctionalTests : LoggedTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task Start_RequestDelegate_Url()
|
||||||
|
{
|
||||||
|
await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync(string.Empty), "StartRequestDelegateUrlApp");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Start_RouteBuilder_Url()
|
||||||
|
{
|
||||||
|
await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync("/route"), "StartRouteBuilderUrlApp");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task StartWith_IApplicationBuilder_Url()
|
||||||
|
{
|
||||||
|
await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync(string.Empty), "StartWithIApplicationBuilderUrlApp");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateDefaultBuilder_InitializeWithDefaults()
|
||||||
|
{
|
||||||
|
var applicationName = "CreateDefaultBuilderApp";
|
||||||
|
await ExecuteTestApp(applicationName, async (deploymentResult, logger) =>
|
||||||
|
{
|
||||||
|
var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken, retryCount: 5);
|
||||||
|
|
||||||
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Assert server is Kestrel
|
||||||
|
Assert.Equal("Kestrel", response.Headers.Server.ToString());
|
||||||
|
// The application name will be sent in response when all asserts succeed in the test app.
|
||||||
|
Assert.Equal(applicationName, responseText);
|
||||||
|
}
|
||||||
|
catch (XunitException)
|
||||||
|
{
|
||||||
|
logger.LogWarning(response.ToString());
|
||||||
|
logger.LogWarning(responseText);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}, setTestEnvVars: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateDefaultBuilderOfT_InitializeWithDefaults()
|
||||||
|
{
|
||||||
|
var applicationName = "CreateDefaultBuilderOfTApp";
|
||||||
|
await ExecuteTestApp(applicationName, async (deploymentResult, logger) =>
|
||||||
|
{
|
||||||
|
var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken, retryCount: 5);
|
||||||
|
|
||||||
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Assert server is Kestrel
|
||||||
|
Assert.Equal("Kestrel", response.Headers.Server.ToString());
|
||||||
|
// The application name will be sent in response when all asserts succeed in the test app.
|
||||||
|
Assert.Equal(applicationName, responseText);
|
||||||
|
}
|
||||||
|
catch (XunitException)
|
||||||
|
{
|
||||||
|
logger.LogWarning(response.ToString());
|
||||||
|
logger.LogWarning(responseText);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}, setTestEnvVars: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Development", "InvalidOperationException: Cannot consume scoped service")]
|
||||||
|
[InlineData("Production", "Success")]
|
||||||
|
public async Task CreateDefaultBuilder_InitializesDependencyInjectionSettingsBasedOnEnv(string environment, string expected)
|
||||||
|
{
|
||||||
|
var applicationName = "DependencyInjectionApp";
|
||||||
|
await ExecuteTestApp(applicationName, async (deploymentResult, logger) =>
|
||||||
|
{
|
||||||
|
var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken);
|
||||||
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Assert UseDeveloperExceptionPage is called in WebHostStartupFilter.
|
||||||
|
Assert.Contains(expected, responseText);
|
||||||
|
}
|
||||||
|
catch (XunitException)
|
||||||
|
{
|
||||||
|
logger.LogWarning(response.ToString());
|
||||||
|
logger.LogWarning(responseText);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}, setTestEnvVars: true, environment: environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void LoggingConfigurationSectionPassedToLoggerByDefault()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllText("appsettings.json", @"
|
||||||
|
{
|
||||||
|
""Logging"": {
|
||||||
|
""LogLevel"": {
|
||||||
|
""Default"": ""Warning""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
");
|
||||||
|
using (var webHost = WebHost.Start("http://127.0.0.1:0", context => context.Response.WriteAsync("Hello, World!")))
|
||||||
|
{
|
||||||
|
var factory = (ILoggerFactory)webHost.Services.GetService(typeof(ILoggerFactory));
|
||||||
|
var logger = factory.CreateLogger("Test");
|
||||||
|
|
||||||
|
logger.Log(LogLevel.Information, 0, "Message", null, (s, e) =>
|
||||||
|
{
|
||||||
|
Assert.True(false);
|
||||||
|
return string.Empty;
|
||||||
|
});
|
||||||
|
|
||||||
|
var logWritten = false;
|
||||||
|
logger.Log(LogLevel.Warning, 0, "Message", null, (s, e) =>
|
||||||
|
{
|
||||||
|
logWritten = true;
|
||||||
|
return string.Empty;
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.True(logWritten);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
File.Delete("appsettings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||||
|
public async Task RunsInIISExpressInProcess()
|
||||||
|
{
|
||||||
|
var applicationName = "CreateDefaultBuilderApp";
|
||||||
|
var deploymentParameters = new DeploymentParameters(Path.Combine(GetTestSitesPath(), applicationName), ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||||
|
{
|
||||||
|
TargetFramework = "netcoreapp2.2",
|
||||||
|
HostingModel = HostingModel.InProcess,
|
||||||
|
AncmVersion = AncmVersion.AspNetCoreModuleV2
|
||||||
|
};
|
||||||
|
|
||||||
|
SetEnvironmentVariables(deploymentParameters, "Development");
|
||||||
|
|
||||||
|
using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory))
|
||||||
|
{
|
||||||
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
|
var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), Logger, deploymentResult.HostShutdownToken, retryCount: 5);
|
||||||
|
|
||||||
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Assert server is IISExpress
|
||||||
|
Assert.Equal("Microsoft-IIS/10.0", response.Headers.Server.ToString());
|
||||||
|
// The application name will be sent in response when all asserts succeed in the test app.
|
||||||
|
Assert.Equal(applicationName, responseText);
|
||||||
|
}
|
||||||
|
catch (XunitException)
|
||||||
|
{
|
||||||
|
Logger.LogWarning(response.ToString());
|
||||||
|
Logger.LogWarning(responseText);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteStartOrStartWithTest(Func<DeploymentResult, Task<HttpResponseMessage>> getResponse, string applicationName)
|
||||||
|
{
|
||||||
|
await ExecuteTestApp(applicationName, async (deploymentResult, logger) =>
|
||||||
|
{
|
||||||
|
var response = await RetryHelper.RetryRequest(() => getResponse(deploymentResult), logger, deploymentResult.HostShutdownToken);
|
||||||
|
|
||||||
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Assert.Equal(applicationName, responseText);
|
||||||
|
}
|
||||||
|
catch (XunitException)
|
||||||
|
{
|
||||||
|
logger.LogWarning(response.ToString());
|
||||||
|
logger.LogWarning(responseText);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteTestApp(string applicationName,
|
||||||
|
Func<DeploymentResult, ILogger, Task> assertAction,
|
||||||
|
bool setTestEnvVars = false,
|
||||||
|
string environment = "Development")
|
||||||
|
{
|
||||||
|
var deploymentParameters = new DeploymentParameters(Path.Combine(GetTestSitesPath(), applicationName), ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64);
|
||||||
|
|
||||||
|
if (setTestEnvVars)
|
||||||
|
{
|
||||||
|
SetEnvironmentVariables(deploymentParameters, environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory))
|
||||||
|
{
|
||||||
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
|
|
||||||
|
await assertAction(deploymentResult, Logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetEnvironmentVariables(DeploymentParameters deploymentParameters, string environment)
|
||||||
|
{
|
||||||
|
deploymentParameters.EnvironmentVariables.Add(new KeyValuePair<string, string>("aspnetcore_environment", environment));
|
||||||
|
deploymentParameters.EnvironmentVariables.Add(new KeyValuePair<string, string>("envKey", "envValue"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetTestSitesPath()
|
||||||
|
{
|
||||||
|
var applicationBasePath = AppContext.BaseDirectory;
|
||||||
|
|
||||||
|
var directoryInfo = new DirectoryInfo(applicationBasePath);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "MetaPackages.sln"));
|
||||||
|
if (solutionFileInfo.Exists)
|
||||||
|
{
|
||||||
|
return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "test", "TestSites"));
|
||||||
|
}
|
||||||
|
|
||||||
|
directoryInfo = directoryInfo.Parent;
|
||||||
|
}
|
||||||
|
while (directoryInfo.Parent != null);
|
||||||
|
|
||||||
|
throw new Exception($"Solution root could not be found using {applicationBasePath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||||
|
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
|
||||||
|
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
// 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.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Tracing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using Microsoft.AspNetCore.HostFiltering;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WebHostConfiguration_HostFilterOptionsAreReloadable()
|
||||||
|
{
|
||||||
|
var host = WebHost.CreateDefaultBuilder()
|
||||||
|
.Configure(app => { })
|
||||||
|
.ConfigureAppConfiguration(configBuilder =>
|
||||||
|
{
|
||||||
|
configBuilder.Add(new ReloadableMemorySource());
|
||||||
|
}).Build();
|
||||||
|
var config = host.Services.GetRequiredService<IConfiguration>();
|
||||||
|
var monitor = host.Services.GetRequiredService<IOptionsMonitor<HostFilteringOptions>>();
|
||||||
|
var options = monitor.CurrentValue;
|
||||||
|
|
||||||
|
Assert.Contains("*", options.AllowedHosts);
|
||||||
|
|
||||||
|
var changed = new ManualResetEvent(false);
|
||||||
|
monitor.OnChange(newOptions =>
|
||||||
|
{
|
||||||
|
changed.Set();
|
||||||
|
});
|
||||||
|
|
||||||
|
config["AllowedHosts"] = "NewHost";
|
||||||
|
|
||||||
|
Assert.True(changed.WaitOne(TimeSpan.FromSeconds(10)));
|
||||||
|
options = monitor.CurrentValue;
|
||||||
|
Assert.Contains("NewHost", options.AllowedHosts);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CreateDefaultBuilder_RegistersEventSourceLogger()
|
||||||
|
{
|
||||||
|
var listener = new TestEventListener();
|
||||||
|
var host = WebHost.CreateDefaultBuilder()
|
||||||
|
.Configure(_ => { })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var logger = host.Services.GetRequiredService<ILogger<WebHostTests>>();
|
||||||
|
logger.LogInformation("Request starting");
|
||||||
|
|
||||||
|
var events = listener.EventData.ToArray();
|
||||||
|
Assert.Contains(events, args =>
|
||||||
|
args.EventSource.Name == "Microsoft-Extensions-Logging" &&
|
||||||
|
args.Payload.OfType<string>().Any(p => p.Contains("Request starting")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestEventListener : EventListener
|
||||||
|
{
|
||||||
|
private volatile bool _disposed;
|
||||||
|
|
||||||
|
private ConcurrentQueue<EventWrittenEventArgs> _events = new ConcurrentQueue<EventWrittenEventArgs>();
|
||||||
|
|
||||||
|
public IEnumerable<EventWrittenEventArgs> EventData => _events;
|
||||||
|
|
||||||
|
protected override void OnEventSourceCreated(EventSource eventSource)
|
||||||
|
{
|
||||||
|
if (eventSource.Name == "Microsoft-Extensions-Logging")
|
||||||
|
{
|
||||||
|
EnableEvents(eventSource, EventLevel.Informational);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnEventWritten(EventWrittenEventArgs eventData)
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
_events.Enqueue(eventData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
_disposed = true;
|
||||||
|
base.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ReloadableMemorySource : IConfigurationSource
|
||||||
|
{
|
||||||
|
public IConfigurationProvider Build(IConfigurationBuilder builder)
|
||||||
|
{
|
||||||
|
return new ReloadableMemoryProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ReloadableMemoryProvider : ConfigurationProvider
|
||||||
|
{
|
||||||
|
public override void Set(string key, string value)
|
||||||
|
{
|
||||||
|
base.Set(key, value);
|
||||||
|
OnReload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
<UserSecretsId>aspnetcore-CreateDefaultBuilder-20170424224131</UserSecretsId>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
// 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 Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CreateDefaultBuilderApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string responseMessage = null;
|
||||||
|
|
||||||
|
WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" })
|
||||||
|
.ConfigureServices((context, services) => responseMessage = responseMessage ?? GetResponseMessage(context))
|
||||||
|
.ConfigureKestrel(options => options
|
||||||
|
.Configure(options.ConfigurationLoader.Configuration)
|
||||||
|
.Endpoint("HTTP", endpointOptions =>
|
||||||
|
{
|
||||||
|
if (responseMessage == null
|
||||||
|
&& !string.Equals("KestrelEndPointSettingValue", endpointOptions.ConfigSection["KestrelEndPointSettingName"]))
|
||||||
|
{
|
||||||
|
responseMessage = "Default Kestrel configuration not read.";
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.Configure(app => app.Run(context =>
|
||||||
|
{
|
||||||
|
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
||||||
|
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
||||||
|
}))
|
||||||
|
.Build().Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetResponseMessage(WebHostBuilderContext context)
|
||||||
|
{
|
||||||
|
// Verify ContentRootPath set
|
||||||
|
var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT");
|
||||||
|
if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify appsettings.json loaded
|
||||||
|
if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"appsettings.json not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify appsettings.environment.json loaded
|
||||||
|
if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify UserSecrets loaded
|
||||||
|
|
||||||
|
// Verify environment variables loaded
|
||||||
|
if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"Environment variables not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify command line arguments loaded
|
||||||
|
if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"Command line arguments not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify AddConsole called
|
||||||
|
// TODO: Verify AddDebug called
|
||||||
|
// TODO: Verify UseIISIntegration called
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"devSettingsKey": "devSettingsValue"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"settingsKey": "settingsValue",
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"HTTP": {
|
||||||
|
"Url": "http://127.0.0.1:0",
|
||||||
|
"KestrelEndPointSettingName": "KestrelEndPointSettingValue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
<UserSecretsId>aspnetcore-CreateDefaultBuilderOfT-20170424224131</UserSecretsId>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// 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 Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.HostFiltering;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace CreateDefaultBuilderOfTApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string responseMessage = null;
|
||||||
|
|
||||||
|
WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" })
|
||||||
|
.ConfigureServices((context, service) => responseMessage = responseMessage ?? GetResponseMessage(context))
|
||||||
|
.ConfigureKestrel(options => options
|
||||||
|
.Configure(options.ConfigurationLoader.Configuration)
|
||||||
|
.Endpoint("HTTP", endpointOptions =>
|
||||||
|
{
|
||||||
|
if (responseMessage == null
|
||||||
|
&& !string.Equals("KestrelEndPointSettingValue", endpointOptions.ConfigSection["KestrelEndPointSettingName"]))
|
||||||
|
{
|
||||||
|
responseMessage = "Default Kestrel configuration not read.";
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.Configure(app => app.Run(context =>
|
||||||
|
{
|
||||||
|
// Verify allowed hosts were loaded
|
||||||
|
var hostFilteringOptions = app.ApplicationServices.GetRequiredService<IOptions<HostFilteringOptions>>();
|
||||||
|
var hosts = string.Join(',', hostFilteringOptions.Value.AllowedHosts);
|
||||||
|
if (responseMessage == null && !string.Equals("example.com,127.0.0.1", hosts, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
responseMessage = "AllowedHosts not loaded into Options.";
|
||||||
|
}
|
||||||
|
|
||||||
|
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
||||||
|
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
||||||
|
}))
|
||||||
|
.Build()
|
||||||
|
.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetResponseMessage(WebHostBuilderContext context)
|
||||||
|
{
|
||||||
|
// Verify ContentRootPath set
|
||||||
|
var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT");
|
||||||
|
if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify appsettings.json loaded
|
||||||
|
if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"appsettings.json not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify appsettings.environment.json loaded
|
||||||
|
if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify UserSecrets loaded
|
||||||
|
|
||||||
|
// Verify environment variables loaded
|
||||||
|
if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"Environment variables not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify command line arguments loaded
|
||||||
|
if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return $"Command line arguments not loaded into Configuration.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify AddConsole called
|
||||||
|
// TODO: Verify AddDebug called
|
||||||
|
// TODO: Verify UseIISIntegration called
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"devSettingsKey": "devSettingsValue"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"settingsKey": "settingsValue",
|
||||||
|
"AllowedHosts": "example.com;127.0.0.1",
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"HTTP": {
|
||||||
|
"Url": "http://127.0.0.1:0",
|
||||||
|
"KestrelEndPointSettingName": "KestrelEndPointSettingValue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
// 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 Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CreateDefaultBuilderApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
WebHost.CreateDefaultBuilder()
|
||||||
|
.UseUrls("http://127.0.0.1:0")
|
||||||
|
.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
services.AddSingleton(typeof(IService<>), typeof(Service<>));
|
||||||
|
services.AddScoped<IAnotherService, AnotherService>();
|
||||||
|
})
|
||||||
|
.Configure(app =>
|
||||||
|
{
|
||||||
|
app.Run(context =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
context.RequestServices.GetService<IService<IAnotherService>>();
|
||||||
|
return context.Response.WriteAsync("Success");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return context.Response.WriteAsync(ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.Build().Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IService<T>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IAnotherService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
class Service<T>: IService<T>
|
||||||
|
{
|
||||||
|
public Service(T t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AnotherService: IAnotherService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// 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.Threading;
|
||||||
|
using Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace StartRequestDelegateUrlApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var messageSent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
|
using (var host = WebHost.Start("http://127.0.0.1:0", async context =>
|
||||||
|
{
|
||||||
|
// Respond with the ApplicationName.
|
||||||
|
var env = context.RequestServices.GetRequiredService<IHostingEnvironment>();
|
||||||
|
await context.Response.WriteAsync(env.ApplicationName);
|
||||||
|
messageSent.Set();
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
// Need these for test deployer to consider host deployment successful
|
||||||
|
// The address written here is used by the client to send requests
|
||||||
|
var addresses = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
||||||
|
foreach (var address in addresses)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Now listening on: {address}");
|
||||||
|
}
|
||||||
|
Console.WriteLine("Application started. Press Ctrl+C to shut down.");
|
||||||
|
|
||||||
|
// Shut down after message sent or timeout
|
||||||
|
messageSent.Wait(TimeSpan.FromSeconds(30));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// 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.Threading;
|
||||||
|
using Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace StartRequestDelegateUrlApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var messageSent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
|
using (var host = WebHost.Start("http://127.0.0.1:0", router =>
|
||||||
|
router.MapGet("route", async (req, res, data) =>
|
||||||
|
{
|
||||||
|
var env = req.HttpContext.RequestServices.GetRequiredService<IHostingEnvironment>();
|
||||||
|
await res.WriteAsync(env.ApplicationName);
|
||||||
|
messageSent.Set();
|
||||||
|
})))
|
||||||
|
{
|
||||||
|
// Need these for test deployer to consider host deployment successful
|
||||||
|
// The address written here is used by the client to send requests
|
||||||
|
var addresses = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
||||||
|
foreach (var address in addresses)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Now listening on: {address}");
|
||||||
|
}
|
||||||
|
Console.WriteLine("Application started. Press Ctrl+C to shut down.");
|
||||||
|
|
||||||
|
// Shut down after message sent or timeout
|
||||||
|
messageSent.Wait(TimeSpan.FromSeconds(30));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
// 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.Threading;
|
||||||
|
using Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace StartWithIApplicationBuilderUrlApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var messageSent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
|
using (var host = WebHost.StartWith("http://127.0.0.1:0", app =>
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
var env = context.RequestServices.GetRequiredService<IHostingEnvironment>();
|
||||||
|
await context.Response.WriteAsync(env.ApplicationName);
|
||||||
|
messageSent.Set();
|
||||||
|
});
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
// Need these for test deployer to consider host deployment successful
|
||||||
|
// The address written here is used by the client to send requests
|
||||||
|
var addresses = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
||||||
|
foreach (var address in addresses)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Now listening on: {address}");
|
||||||
|
}
|
||||||
|
Console.WriteLine("Application started. Press Ctrl+C to shut down.");
|
||||||
|
|
||||||
|
// Shut down after message sent or timeout
|
||||||
|
messageSent.Wait(TimeSpan.FromSeconds(30));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<VersionPrefix>2.2.0</VersionPrefix>
|
||||||
|
<VersionSuffix>rtm</VersionSuffix>
|
||||||
|
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND ('$(VersionSuffix)' == 'servicing' OR '$(VersionSuffix)' == 'rtm') ">$(VersionPrefix)</PackageVersion>
|
||||||
|
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'servicing' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
|
||||||
|
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>
|
||||||
|
<FeatureBranchVersionPrefix Condition="'$(FeatureBranchVersionPrefix)' == ''">a-</FeatureBranchVersionPrefix>
|
||||||
|
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(FeatureBranchVersionSuffix)' != ''">$(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))</VersionSuffix>
|
||||||
|
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
Loading…
Reference in New Issue