Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Updated to ASP.NET Core 3.1 (#4222)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbrady91 authored Mar 30, 2020
1 parent ad12f11 commit 9fb1aee
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 94 deletions.
10 changes: 3 additions & 7 deletions samples/KeyManagement/FileSystem/FileSystemSample.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="IdentityServer4.KeyManagement" Version="1.0.8" />
<PackageReference Include="IdentityServer4.KeyManagement" Version="2.0.4" />

<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
35 changes: 14 additions & 21 deletions samples/KeyManagement/FileSystem/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

using Microsoft.AspNetCore.Hosting;
using System;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using Microsoft.AspNetCore;
using Microsoft.Extensions.Logging;
using Serilog;

namespace sample
{
Expand All @@ -18,29 +17,23 @@ public static void Main(string[] args)
{
Console.Title = "IdentityServer4";

BuildWebHost(args).Run();
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHost BuildWebHost(string[] args)
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.File(@"identityserver4_log.txt")
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate)
.CreateLogger();

return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(builder =>
{
builder.ClearProviders();
builder.AddSerilog();
})
.Build();
.UseStartup<Startup>()
.UseSerilog((context, configuration) =>
{
configuration
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate);
});
}
}
}
7 changes: 4 additions & 3 deletions samples/KeyManagement/FileSystem/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.


Expand All @@ -11,14 +11,15 @@
using System.Linq;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;

namespace sample
{
public class Startup
{
public IHostingEnvironment Environment { get; }
public IWebHostEnvironment Environment { get; }

public Startup(IConfiguration config, IHostingEnvironment environment)
public Startup(IConfiguration config, IWebHostEnvironment environment)
{
Environment = environment;
}
Expand Down
11 changes: 4 additions & 7 deletions samples/KeyManagement/database/EF/EfSample.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="IdentityServer4.KeyManagement.EntityFramework" Version="1.0.8" />
<PackageReference Include="IdentityServer4.KeyManagement.EntityFramework" Version="2.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />

<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
</ItemGroup>

</Project>
33 changes: 13 additions & 20 deletions samples/KeyManagement/database/EF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using Microsoft.AspNetCore;
using Microsoft.Extensions.Logging;

namespace sample
{
Expand All @@ -18,29 +17,23 @@ public static void Main(string[] args)
{
Console.Title = "IdentityServer4";

BuildWebHost(args).Run();
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHost BuildWebHost(string[] args)
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.File(@"identityserver4_log.txt")
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate)
.CreateLogger();

return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(builder =>
{
builder.ClearProviders();
builder.AddSerilog();
})
.Build();
.UseStartup<Startup>()
.UseSerilog((context, configuration) =>
{
configuration
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate);
});
}
}
}
7 changes: 4 additions & 3 deletions samples/KeyManagement/database/EF/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.


Expand All @@ -12,17 +12,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace sample
{
public class Startup
{
public IConfiguration Configuration { get; }
public IHostingEnvironment Environment { get; }
public IWebHostEnvironment Environment { get; }
public ILoggerFactory LoggerFactory { get; set; }

public Startup(IConfiguration config, IHostingEnvironment environment, ILoggerFactory loggerFactory)
public Startup(IConfiguration config, IWebHostEnvironment environment, ILoggerFactory loggerFactory)
{
Configuration = config;
Environment = environment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CREATE UNIQUE INDEX [IX_SigningKeys_Name] ON [SigningKeys] ([Name]) WHERE [Name]
GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20190910134450_KeyManagement', N'2.1.11-servicing-32099');
VALUES (N'20200327143521_KeyManagement', N'3.1.3');

GO

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace migrations.Migrations.KeyManagement
Expand All @@ -13,7 +12,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
.Annotation("SqlServer:Identity", "1, 1"),
Created = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(maxLength: 200, nullable: true),
Value = table.Column<string>(nullable: false)
Expand All @@ -28,7 +27,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
.Annotation("SqlServer:Identity", "1, 1"),
Created = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(maxLength: 200, nullable: true),
Value = table.Column<string>(nullable: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,27 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.11-servicing-32099")
.HasAnnotation("ProductVersion", "3.1.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

modelBuilder.Entity("IdentityServer4.KeyManagement.EntityFramework.DataProtectionKey", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Created");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Value")
.IsRequired();
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
Expand All @@ -46,15 +50,19 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Created");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Value")
.IsRequired();
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
Expand Down
9 changes: 1 addition & 8 deletions samples/KeyManagement/database/migrations/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace migrations
{
Expand Down
7 changes: 1 addition & 6 deletions samples/KeyManagement/database/migrations/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IdentityServer4.KeyManagement.EntityFramework;
using IdentityServer4.KeyManagement.EntityFramework;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down
8 changes: 5 additions & 3 deletions samples/KeyManagement/database/migrations/migrations.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 9fb1aee

Please sign in to comment.