Merge remote-tracking branch 'MetaPackages/rybrande/release21ToSrc' into rybrande/Mondo2.1
This commit is contained in:
commit
f98aa3b4a3
|
|
@ -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,21 @@
|
|||
<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>
|
||||
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(MicrosoftNETCoreApp20PackageVersion)</RuntimeFrameworkVersion>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">$(MicrosoftNETCoreApp21PackageVersion)</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">$(NETStandardLibrary20PackageVersion)</NETStandardImplicitPackageVersion>
|
||||
</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>
|
||||
|
||||
<!-- These package versions may be overridden or updated by automation. -->
|
||||
<PropertyGroup Label="Package Versions: Auto">
|
||||
<InternalAspNetCoreSdkPackageVersion>2.1.3-rtm-15802</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.1</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostFilteringPackageVersion>2.1.1</MicrosoftAspNetCoreHostFilteringPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>2.1.1</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreRoutingPackageVersion>2.1.1</MicrosoftAspNetCoreRoutingPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.1</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.1</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelHttpsPackageVersion>2.1.2</MicrosoftAspNetCoreServerKestrelHttpsPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.2</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.1</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.1</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
|
||||
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.1</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationFileExtensionsPackageVersion>2.1.1</MicrosoftExtensionsConfigurationFileExtensionsPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.1</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationUserSecretsPackageVersion>2.1.1</MicrosoftExtensionsConfigurationUserSecretsPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.1</MicrosoftExtensionsLoggingConfigurationPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.1</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.1</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<MicrosoftExtensionsLoggingPackageVersion>2.1.1</MicrosoftExtensionsLoggingPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.2</MicrosoftNETCoreApp21PackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
||||
<MoqPackageVersion>4.7.49</MoqPackageVersion>
|
||||
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
||||
<XunitPackageVersion>2.3.1</XunitPackageVersion>
|
||||
<XunitRunnerVisualStudioPackageVersion>2.4.0-beta.1.build3945</XunitRunnerVisualStudioPackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- This may import a generated file which may override the variables above. -->
|
||||
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
|
||||
|
||||
<!-- These are package versions that should not be overridden or updated by automation. -->
|
||||
<PropertyGroup Label="Package Versions: Pinned" />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<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.1.0-rc1-*</LineupPackageVersion>
|
||||
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json</LineupPackageRestoreSource>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp20PackageVersion)" />
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp21PackageVersion)" />
|
||||
</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.1;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,30 @@
|
|||
<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.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" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
// 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,
|
||||
/// configures the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||
/// enables IIS integration,
|
||||
/// and enables the ability for frameworks to bind their options to their default configuration sections.
|
||||
/// </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,
|
||||
/// configures the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||
/// enables IIS integration,
|
||||
/// and enables the ability for frameworks to bind their options to their default configuration sections.
|
||||
/// </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()
|
||||
.UseKestrel((builderContext, options) =>
|
||||
{
|
||||
options.Configure(builderContext.Configuration.GetSection("Kestrel"));
|
||||
})
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.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();
|
||||
})
|
||||
.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>();
|
||||
})
|
||||
.UseIISIntegration()
|
||||
.UseDefaultServiceProvider((context, options) =>
|
||||
{
|
||||
options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
|
||||
});
|
||||
|
||||
if (args != null)
|
||||
{
|
||||
builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build());
|
||||
}
|
||||
|
||||
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,
|
||||
/// configures the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||
/// enables IIS integration,
|
||||
/// enables the ability for frameworks to bind their options to their default configuration sections.
|
||||
/// </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.1</DeveloperBuildTestTfms>
|
||||
<StandardTestTfms>$(DeveloperBuildTestTfms)</StandardTestTfms>
|
||||
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' ">netcoreapp2.1;netcoreapp2.0</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,28 @@
|
|||
<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.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,238 @@
|
|||
// 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.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.AspNetCore.Tests
|
||||
{
|
||||
public class WebHostFunctionalTests : LoggedTest
|
||||
{
|
||||
private readonly string _testSitesPath;
|
||||
|
||||
public WebHostFunctionalTests(ITestOutputHelper output) : base(output)
|
||||
{
|
||||
_testSitesPath = GetTestSitesPath();
|
||||
}
|
||||
|
||||
[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);
|
||||
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
// Assert server is Kestrel
|
||||
Assert.Equal("Kestrel", response.Headers.Server.ToString());
|
||||
// Set from default config
|
||||
Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri);
|
||||
// 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);
|
||||
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
// Assert server is Kestrel
|
||||
Assert.Equal("Kestrel", response.Headers.Server.ToString());
|
||||
// Set from default config
|
||||
Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri);
|
||||
// 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(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");
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
using (StartLog(out var loggerFactory, applicationName))
|
||||
{
|
||||
var logger = loggerFactory.CreateLogger(nameof(WebHost.Start));
|
||||
var deploymentParameters = new DeploymentParameters(Path.Combine(_testSitesPath, applicationName), ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64);
|
||||
|
||||
if (setTestEnvVars)
|
||||
{
|
||||
deploymentParameters.EnvironmentVariables.Add(new KeyValuePair<string, string>("aspnetcore_environment", environment));
|
||||
deploymentParameters.EnvironmentVariables.Add(new KeyValuePair<string, string>("envKey", "envValue"));
|
||||
}
|
||||
|
||||
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
||||
{
|
||||
var deploymentResult = await deployer.DeployAsync();
|
||||
|
||||
await assertAction(deploymentResult, logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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}");
|
||||
}
|
||||
|
||||
private static int GetWebHostPort(IWebHost webHost)
|
||||
=> webHost.ServerFeatures.Get<IServerAddressesFeature>().Addresses
|
||||
.Select(serverAddress => new Uri(serverAddress).Port)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
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,69 @@
|
|||
// 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.HostFiltering;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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);
|
||||
}
|
||||
|
||||
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.0</TargetFramework>
|
||||
<UserSecretsId>aspnetcore-CreateDefaultBuilder-20170424224131</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.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 = string.Empty;
|
||||
|
||||
WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" })
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
responseMessage = GetResponseMessage(context, services);
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.Run(context =>
|
||||
{
|
||||
return context.Response.WriteAsync(responseMessage);
|
||||
});
|
||||
})
|
||||
.Build().Run();
|
||||
}
|
||||
|
||||
private static string GetResponseMessage(WebHostBuilderContext context, IServiceCollection services)
|
||||
{
|
||||
// Verify ContentRootPath set
|
||||
if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal))
|
||||
{
|
||||
return $"Current directory incorrect. Expected: {Directory.GetCurrentDirectory()} 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 context.HostingEnvironment.ApplicationName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"devSettingsKey": "devSettingsValue"
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"settingsKey": "settingsValue",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"HTTP": {
|
||||
"Url": "http://localhost:5002"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<UserSecretsId>aspnetcore-CreateDefaultBuilderOfT-20170424224131</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// 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;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace CreateDefaultBuilderOfTApp
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args) => WebHost.CreateDefaultBuilder<Startup>(new[] { "--cliKey", "cliValue" }) .Build().Run();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.HostFiltering;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace CreateDefaultBuilderOfTApp
|
||||
{
|
||||
class Startup
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, WebHostBuilderContext webHostBuilderContext)
|
||||
{
|
||||
app.Run(context =>
|
||||
{
|
||||
var message = GetResponseMessage(webHostBuilderContext, app.ApplicationServices.GetRequiredService<IOptions<HostFilteringOptions>>());
|
||||
return context.Response.WriteAsync(message);
|
||||
});
|
||||
}
|
||||
|
||||
private static string GetResponseMessage(WebHostBuilderContext context, IOptions<HostFilteringOptions> hostFilteringOptions)
|
||||
{
|
||||
// Verify ContentRootPath set
|
||||
if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal))
|
||||
{
|
||||
return $"Current directory incorrect. Expected: {Directory.GetCurrentDirectory()} 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.";
|
||||
}
|
||||
|
||||
// Verify allowed hosts were loaded
|
||||
var hosts = string.Join(',', hostFilteringOptions.Value.AllowedHosts);
|
||||
if (!string.Equals("example.com,localhost", hosts, StringComparison.Ordinal))
|
||||
{
|
||||
return $"AllowedHosts not loaded into Options.";
|
||||
}
|
||||
|
||||
// TODO: Verify AddConsole called
|
||||
// TODO: Verify AddDebug called
|
||||
// TODO: Verify UseIISIntegration called
|
||||
|
||||
return context.HostingEnvironment.ApplicationName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"devSettingsKey": "devSettingsValue"
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"settingsKey": "settingsValue",
|
||||
"AllowedHosts": "example.com;localhost",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"HTTP": {
|
||||
"Url": "http://localhost:5002"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
// 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.Linq;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
using Microsoft.Extensions.Logging.Debug;
|
||||
|
||||
namespace CreateDefaultBuilderApp
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
WebHost.CreateDefaultBuilder()
|
||||
.UseUrls("http://localhost:5002")
|
||||
.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.0</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.0</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.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>2.1.7</VersionPrefix>
|
||||
<VersionSuffix>servicing</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