Skip to content

Instantly share code, notes, and snippets.

View WernerMairl's full-sized avatar

Werner Mairl WernerMairl

  • Vienna
View GitHub Profile
<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" />
<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>
@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()
// 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 / fullsettings.json
Created July 20, 2017 05:00
SettingsFile With Sections
{
"AppSettings": {
"Setting1": "value1",
"Setting2": "value2"
},
"Hosting": {
"urls": "https://*:5000",
"environment": "Production"
}
}
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.build();
var host = new WebHostBuilder()
.UseConfiguration(config.GetSection("Hosting"))
FROM openjdk:8-jdk-stretch
ENV PWSH_VERSION 6.0.4*
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils && apt-get install --no-install-recommends -y curl gnupg apt-transport-https \
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list' \
&& apt-get update && apt-get install --no-install-recommends -y powershell=${PWSH_VERSION} \
&& rm -rf /var/lib/apt/lists/*
using System;
using System.IO;
.....
[Fact]
public void CreationTimeUtc_Bug()
{
@WernerMairl
WernerMairl / program.cs
Created March 2, 2019 15:54
Create Jwt Bearer Token (sample)
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using Microsoft.IdentityModel.Tokens;
namespace ConsoleApp1
{
class Program
{