Skip to content

Commit 4750b7e

Browse files
authored
Merge pull request #11 from reloni/reloni/ch215/update-to-net-core-2-1
Update to .net core 2.1
2 parents beb18ec + e119a08 commit 4750b7e

11 files changed

Lines changed: 35 additions & 33 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ Thumbs.db
4343
/Scripts/restore.log
4444
/restore.log
4545
/.vs/SimpleToDoService/xs/UserPrefs.xml
46+
/.vs

Dockerfile.debug

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM microsoft/aspnetcore:2.0.5-stretch
1+
FROM microsoft/dotnet:2.1.1-aspnetcore-runtime-stretch-slim
22

33
# Install the AWS CLI
44
RUN apt-get update && \
5+
mkdir -p /usr/share/man/man1 /usr/share/man/man7 && \
56
apt-get install -y postgresql-client-9.6 && \
67
apt-get -y install python curl unzip && cd /tmp && \
78
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" \

Dockerfile.release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM microsoft/aspnetcore:2.0.5-stretch
1+
FROM microsoft/dotnet:2.1.1-aspnetcore-runtime-stretch-slim
22

33
# Install the AWS CLI
44
RUN apt-get update && \

RequestTests.paw

-435 Bytes
Binary file not shown.

Scripts/Publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
export DOTNETSDK="2.0.5-sdk-2.1.4-stretch"
5+
export DOTNETSDK="2.1.301-sdk-stretch"
66

77
docker run -it -d --name builder microsoft/dotnet:"$DOTNETSDK" tail -f /dev/null
88

src/SimpleToDoService/Middleware/CheckUserMiddleware.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,29 @@ namespace SimpleToDoService.Middleware
1010
public class CheckUserMiddleware
1111
{
1212
private readonly RequestDelegate next;
13-
private IToDoRepository repository;
1413

1514
public CheckUserMiddleware() { }
1615

17-
public CheckUserMiddleware(RequestDelegate next, IToDoRepository repository)
16+
public CheckUserMiddleware(RequestDelegate next)
1817
{
1918
this.next = next;
20-
this.repository = repository;
2119
}
2220

2321
public void Configure(IApplicationBuilder applicationBuilder)
2422
{
2523
applicationBuilder.UseMiddleware<CheckUserMiddleware>();
2624
}
2725

28-
public async System.Threading.Tasks.Task Invoke(HttpContext context)
26+
public async System.Threading.Tasks.Task Invoke(HttpContext context, IToDoRepository repository)
2927
{
3028
if (context.User.Identity.IsAuthenticated && !context.Items.Keys.Contains("UserUuid"))
3129
{
32-
context.Items.Add("UserUuid", LoadUserGuid(context));
30+
context.Items.Add("UserUuid", LoadUserGuid(context, repository));
3331
}
3432
await next.Invoke(context);
3533
}
3634

37-
private Guid LoadUserGuid(HttpContext context)
35+
private Guid LoadUserGuid(HttpContext context, IToDoRepository repository)
3836
{
3937
var providerId = context.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
4038
var currentUser = repository.UserByProviderId(providerId);

src/SimpleToDoService/Program.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
1+
using Microsoft.AspNetCore;
62
using Microsoft.AspNetCore.Hosting;
3+
using NLog.Web;
74

85
namespace SimpleToDoService
96
{
107
public class Program
118
{
129
public static void Main(string[] args)
1310
{
14-
var host = new WebHostBuilder()
11+
CreateWebHostBuilder(args)
1512
.UseKestrel()
16-
//.UseContentRoot(Directory.GetCurrentDirectory())
17-
.UseStartup<Startup>()
18-
.Build();
19-
20-
host.Run();
13+
.Build()
14+
.Run();
2115
}
16+
17+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
18+
WebHost.CreateDefaultBuilder(args)
19+
.UseStartup<Startup>()
20+
.UseNLog();
2221
}
2322
}
23+

src/SimpleToDoService/SimpleToDoService.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
1+
<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
55
<PreserveCompilationContext>true</PreserveCompilationContext>
66
<DebugType>Portable</DebugType>
77
<RootNamespace>SimpleToDoService</RootNamespace>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
12-
<PackageReference Include="NLog.Web.AspNetCore" Version="4.4.1" />
13-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
14-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.0.0-preview2-final" />
11+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
12+
<PackageReference Include="Microsoft.AspNetCore.App" />
13+
<PackageReference Include="NLog.Web.AspNetCore" Version="4.5.4" />
14+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.0" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/SimpleToDoService/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
9999
loggerFactory.AddNLog();
100100

101101
//add NLog.Web
102-
app.AddNLogWeb();
102+
//app.AddNLogWeb();
103103

104104
//configure nlog.config in your project root.
105105
env.ConfigureNLog("nlog.config");

src/SimpleToDoServiceTests/SimpleToDoServiceTests.csproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="xunit" Version="2.2.0" />
9-
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
8+
<PackageReference Include="xunit" Version="2.3.1" />
9+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.1.1" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.1.1" />
1113
</ItemGroup>
1214

1315
<ItemGroup>

0 commit comments

Comments
 (0)