Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Commit ab5daa3

Browse files
DamianEdwardsJunTaoLuo
authored andcommitted
Adds new WebHost API for creating IWebHost & IWebHostBuilder with defaults:
- #24
1 parent 198fe34 commit ab5daa3

File tree

11 files changed

+362
-3
lines changed

11 files changed

+362
-3
lines changed

MetaPackages.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1
2020
build\repo.targets = build\repo.targets
2121
EndProjectSection
2222
EndProject
23+
2324
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RuntimeStore", "src\Microsoft.AspNetCore.RuntimeStore\Microsoft.AspNetCore.RuntimeStore.csproj", "{A4585E19-FC49-43B4-9416-0BD3120EAD32}"
2425
EndProject
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}"
27+
EndProject
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}"
29+
EndProject
2530
Global
2631
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2732
Debug|Any CPU = Debug|Any CPU
@@ -36,6 +41,10 @@ Global
3641
{CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU
3742
{CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU
3843
{CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU
3948
{A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4049
{A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.Build.0 = Debug|Any CPU
4150
{A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -48,6 +57,7 @@ Global
4857
{6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}
4958
{CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}
5059
{F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F}
60+
{AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274}
5161
{A4585E19-FC49-43B4-9416-0BD3120EAD32} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}
5262
EndGlobalSection
5363
EndGlobal

build/Key.snk

596 Bytes
Binary file not shown.

build/common.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
<MetaPackagePackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
3232
<MetaPackagePackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
3333
<MetaPackagePackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
34+
<MetaPackagePackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
35+
<MetaPackagePackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
3436
<MetaPackagePackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
3537
<MetaPackagePackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
3638
<MetaPackagePackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
@@ -129,10 +131,8 @@
129131
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
130132
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
131133
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
132-
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
133134
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.DockerSecrets" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
134135
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
135-
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
136136
<FullMetaPackagePackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
137137
<FullMetaPackagePackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(AspNetCoreVersion)" PrivateAssets="None" />
138138
<FullMetaPackagePackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(AspNetCoreVersion)" PrivateAssets="None" />

build/dependencies.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<CoreFxVersion>4.3.0</CoreFxVersion>
66
<InternalAspNetCoreSdkVersion>2.0.0-*</InternalAspNetCoreSdkVersion>
77
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
8+
<RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion>
89
</PropertyGroup>
910
</Project>

samples/SampleApp/Program.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.AspNetCore.Http;
9+
using Microsoft.AspNetCore.Routing;
10+
11+
namespace SampleApp
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
// HelloWorld();
18+
19+
// CustomUrl();
20+
21+
// Router();
22+
23+
StartupClass(args);
24+
}
25+
26+
private static void HelloWorld()
27+
{
28+
var host = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"));
29+
//host.WaitForShutdown(); // TODO: This method needs to be added to Hosting
30+
}
31+
32+
private static void CustomUrl()
33+
{
34+
// Changing the listening URL
35+
var host = WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!"));
36+
//host.WaitForShutdown(); // TODO: This method needs to be added to Hosting
37+
}
38+
39+
private static void Router()
40+
{
41+
// Using a router
42+
var host = WebHost.Start(router => router
43+
.MapGet("/hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}"))
44+
.MapGet("/goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}"))
45+
.MapGet("/{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}"))
46+
.MapGet("/", (req, res, data) => res.WriteAsync($"Hello, World!"))
47+
);
48+
//host.WaitForShutdown(); // TODO: This method needs to be added to Hosting
49+
}
50+
51+
private static void StartupClass(string[] args)
52+
{
53+
// Using defaults with a Startup class
54+
var host = WebHost.CreateDefaultBuilder(args)
55+
.UseStartup<Startup>()
56+
.Build();
57+
host.Run();
58+
}
59+
}
60+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:53432/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"SampleApp": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development"
23+
},
24+
"applicationUrl": "http://localhost:53433"
25+
}
26+
}
27+
}

samples/SampleApp/SampleApp.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<Import Project="..\..\build\common.props" />
4+
5+
<PropertyGroup>
6+
<TargetFramework>netcoreapp2.0</TargetFramework>
7+
<UserSecretsId>aspnetcore-MetaPackagesSampleApp-20170406180413</UserSecretsId>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Folder Include="wwwroot\" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
16+
</ItemGroup>
17+
18+
</Project>

samples/SampleApp/Startup.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace SampleApp
12+
{
13+
public class Startup
14+
{
15+
public void ConfigureServices(IServiceCollection services)
16+
{
17+
18+
}
19+
20+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
21+
{
22+
app.Run(async (context) =>
23+
{
24+
await context.Response.WriteAsync("Hello World!");
25+
});
26+
}
27+
}
28+
}

src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
<Import Project="..\..\build\common.props" />
44

55
<PropertyGroup>
6-
<IncludeBuildOutput>false</IncludeBuildOutput>
6+
<IncludeBuildOutput>true</IncludeBuildOutput>
77
<TargetFramework>netstandard1.3</TargetFramework>
88
<PackageTags>aspnetcore</PackageTags>
99
<Description>Microsoft.AspNetCore</Description>
10+
<AssemblyOriginatorKeyFile>..\..\build\Key.snk</AssemblyOriginatorKeyFile>
11+
<SignAssembly>true</SignAssembly>
12+
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
1013
</PropertyGroup>
1114

1215
<ItemGroup>

0 commit comments

Comments
 (0)