Skip to content

Instantly share code, notes, and snippets.

View WernerMairl's full-sized avatar

Werner Mairl WernerMairl

  • Vienna
View GitHub Profile
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.build();
var host = new WebHostBuilder()
.UseConfiguration(config.GetSection("Hosting"))
@WernerMairl
WernerMairl / fullsettings.json
Created July 20, 2017 05:00
SettingsFile With Sections
{
"AppSettings": {
"Setting1": "value1",
"Setting2": "value2"
},
"Hosting": {
"urls": "https://*:5000",
"environment": "Production"
}
}
// 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.
namespace Microsoft.AspNetCore.Hosting
{
public static class WebHostDefaults
{
public static readonly string ApplicationKey = "applicationName";
public static readonly string StartupAssemblyKey = "startupAssembly";
@WernerMairl
WernerMairl / program.cs
Created July 20, 2017 04:35
WebHost Default Sample
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddJsonFile("hosting.json", optional: true)
.AddCommandLine(args)
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG;ASSERT;NETCOREAPP2_0</DefineConstants>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170601-03" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="xunit" Version="2.3.0-beta3-build3705" />