Skip to content

Commit aa6a63d

Browse files
committedNov 22, 2020
Update Chapter 22 to .NET 5
1 parent 57e2cfb commit aa6a63d

File tree

28 files changed

+153
-133
lines changed

28 files changed

+153
-133
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
4+
VisualStudioVersion = 16.0.30709.132
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundServiceCache", "BackgroundServiceCache\BackgroundServiceCache.csproj", "{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundServiceCache", "BackgroundServiceCache\BackgroundServiceCache.csproj", "{AC83D419-82F7-46E8-8455-79B3D0FBFA6B}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{AC83D419-82F7-46E8-8455-79B3D0FBFA6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AC83D419-82F7-46E8-8455-79B3D0FBFA6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AC83D419-82F7-46E8-8455-79B3D0FBFA6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AC83D419-82F7-46E8-8455-79B3D0FBFA6B}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {A4F775D9-10A7-4412-A873-F15AB39145DB}
23+
SolutionGuid = {94AF0384-43C8-4251-A05F-25114DB41908}
2424
EndGlobalSection
2525
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

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

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.6" />
9-
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
8+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" NoWarn="NU1605" />
9+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" NoWarn="NU1605" />
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
11+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.0" />
12+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
1013
</ItemGroup>
1114

1215
</Project>

‎Chapter22/A_BackgroundServiceCache/BackgroundServiceCache/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Hosting;
62
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.Hosting;
84
using Microsoft.Extensions.Logging;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
99

1010
namespace BackgroundServiceCache
1111
{

‎Chapter22/A_BackgroundServiceCache/BackgroundServiceCache/Properties/launchSettings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"profiles": {
44
"BackgroundServiceCache": {
55
"commandName": "Project",
6+
"dotnetRunMessages": "true",
67
"launchBrowser": true,
7-
"launchUrl": "values",
8+
"launchUrl": "swagger",
89
"applicationUrl": "https://localhost:5001;http://localhost:5000",
910
"environmentVariables": {
1011
"ASPNETCORE_ENVIRONMENT": "Development"

‎Chapter22/A_BackgroundServiceCache/BackgroundServiceCache/Startup.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Builder;
62
using Microsoft.AspNetCore.Hosting;
73
using Microsoft.AspNetCore.HttpsPolicy;
@@ -11,7 +7,12 @@
117
using Microsoft.Extensions.Hosting;
128
using Microsoft.Extensions.Logging;
139
using Microsoft.Net.Http.Headers;
10+
using Microsoft.OpenApi.Models;
1411
using Polly;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Threading.Tasks;
1516

1617
namespace BackgroundServiceCache
1718
{
@@ -28,6 +29,10 @@ public Startup(IConfiguration configuration)
2829
public void ConfigureServices(IServiceCollection services)
2930
{
3031
services.AddControllers();
32+
services.AddSwaggerGen(c =>
33+
{
34+
c.SwaggerDoc("v1", new OpenApiInfo { Title = "BackgroundServiceCache", Version = "v1" });
35+
});
3136
services.AddHttpClient<ExchangeRatesClient>(client =>
3237
{
3338
client.BaseAddress = new Uri("https://api.exchangeratesapi.io");
@@ -46,6 +51,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4651
if (env.IsDevelopment())
4752
{
4853
app.UseDeveloperExceptionPage();
54+
app.UseSwagger();
55+
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BackgroundServiceCache v1"));
4956
}
5057

5158
app.UseHttpsRedirection();
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
4+
VisualStudioVersion = 16.0.30709.132
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundServiceDatabaseCache", "BackgroundServiceDatabaseCache\BackgroundServiceDatabaseCache.csproj", "{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundServiceDatabaseCache", "BackgroundServiceDatabaseCache\BackgroundServiceDatabaseCache.csproj", "{166BEBA0-3668-44D0-B924-EA4EFE2EF06F}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{5A465FF4-4FE7-43F8-8A97-C48E2991F5C5}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{166BEBA0-3668-44D0-B924-EA4EFE2EF06F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{166BEBA0-3668-44D0-B924-EA4EFE2EF06F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{166BEBA0-3668-44D0-B924-EA4EFE2EF06F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{166BEBA0-3668-44D0-B924-EA4EFE2EF06F}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {A4F775D9-10A7-4412-A873-F15AB39145DB}
23+
SolutionGuid = {307D2D35-465E-4F6B-92A5-88F8C987AEF9}
2424
EndGlobalSection
2525
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

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

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6">
8+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" NoWarn="NU1605" />
9+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" NoWarn="NU1605" />
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
912
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1013
<PrivateAssets>all</PrivateAssets>
1114
</PackageReference>
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.6" />
13-
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.6" />
14-
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
16+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.0" />
17+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
1518
</ItemGroup>
19+
1620
</Project>

‎Chapter22/B_BackgroundServiceDatabaseCache/BackgroundServiceDatabaseCache/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Hosting;
62
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.Hosting;
84
using Microsoft.Extensions.Logging;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
99

1010
namespace BackgroundServiceDatabaseCache
1111
{

‎Chapter22/B_BackgroundServiceDatabaseCache/BackgroundServiceDatabaseCache/Properties/launchSettings.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"$schema": "http://json.schemastore.org/launchsettings.json",
33
"profiles": {
4-
"BackgroundServiceCache": {
4+
"BackgroundServiceDatabaseCache": {
55
"commandName": "Project",
6+
"dotnetRunMessages": "true",
67
"launchBrowser": true,
7-
"launchUrl": "values",
8+
"launchUrl": "swagger",
89
"applicationUrl": "https://localhost:5001;http://localhost:5000",
910
"environmentVariables": {
1011
"ASPNETCORE_ENVIRONMENT": "Development"

‎Chapter22/B_BackgroundServiceDatabaseCache/BackgroundServiceDatabaseCache/Startup.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using BackgroundServiceDatabaseCache.Controllers;
61
using BackgroundServiceDatabaseCache.Data;
72
using Microsoft.AspNetCore.Builder;
83
using Microsoft.AspNetCore.Hosting;
@@ -13,8 +8,11 @@
138
using Microsoft.Extensions.DependencyInjection;
149
using Microsoft.Extensions.Hosting;
1510
using Microsoft.Extensions.Logging;
16-
using Microsoft.Net.Http.Headers;
17-
using Polly;
11+
using Microsoft.OpenApi.Models;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Threading.Tasks;
1816

1917
namespace BackgroundServiceDatabaseCache
2018
{
@@ -35,6 +33,10 @@ public void ConfigureServices(IServiceCollection services)
3533
);
3634

3735
services.AddControllers();
36+
services.AddSwaggerGen(c =>
37+
{
38+
c.SwaggerDoc("v1", new OpenApiInfo { Title = "BackgroundServiceDatabaseCache", Version = "v1" });
39+
});
3840
services.AddHttpClient<ExchangeRatesClient>();
3941
services.AddHostedService<ExchangeRatesHostedService>();
4042
}
@@ -45,6 +47,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4547
if (env.IsDevelopment())
4648
{
4749
app.UseDeveloperExceptionPage();
50+
app.UseSwagger();
51+
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BackgroundServiceDatabaseCache v1"));
4852
}
4953

5054
app.UseHttpsRedirection();
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
4+
VisualStudioVersion = 16.0.30709.132
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemdService", "SystemdService\SystemdService.csproj", "{BE11F90D-06AE-43E8-94C4-6AE24F518583}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemdService", "SystemdService\SystemdService.csproj", "{10F9A7E5-D772-405A-A3B3-9EB536C0417F}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{10F9A7E5-D772-405A-A3B3-9EB536C0417F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{10F9A7E5-D772-405A-A3B3-9EB536C0417F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{10F9A7E5-D772-405A-A3B3-9EB536C0417F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{10F9A7E5-D772-405A-A3B3-9EB536C0417F}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {5FD436B6-61D8-4821-A945-D7E5464B0FE6}
23+
SolutionGuid = {15E9BDD7-F1AC-4E45-B235-1A7FBC289AFE}
2424
EndGlobalSection
2525
EndGlobal

‎Chapter22/C_SystemdService/SystemdService/Program.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.EntityFrameworkCore;
62
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.DependencyInjection;
84
using Microsoft.Extensions.Hosting;
9-
using Microsoft.Net.Http.Headers;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
109
using SystemdService.Data;
1110

1211
namespace SystemdService

‎Chapter22/C_SystemdService/SystemdService/Properties/launchSettings.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"profiles": {
33
"SystemdService": {
44
"commandName": "Project",
5+
"dotnetRunMessages": "true",
56
"environmentVariables": {
67
"DOTNET_ENVIRONMENT": "Development"
78
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk.Worker">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<UserSecretsId>dotnet-SystemdService-2AB7067A-5088-4277-B226-DC0A790AB790</UserSecretsId>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<UserSecretsId>dotnet-SystemdService-9D13B156-AFCF-447B-9BEE-CA453CA6F3D7</UserSecretsId>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.6" />
10-
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.6" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6" PrivateAssets="All" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.6" />
13-
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="3.1.6" />
9+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
10+
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0" PrivateAssets="All" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.0" />
1414
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
1515
</ItemGroup>
1616
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
4+
VisualStudioVersion = 16.0.30709.132
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsService", "WindowsService\WindowsService.csproj", "{BE11F90D-06AE-43E8-94C4-6AE24F518583}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsService", "WindowsService\WindowsService.csproj", "{E26D9308-D5EF-45C2-A4C8-77715EE88A99}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{E26D9308-D5EF-45C2-A4C8-77715EE88A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E26D9308-D5EF-45C2-A4C8-77715EE88A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E26D9308-D5EF-45C2-A4C8-77715EE88A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E26D9308-D5EF-45C2-A4C8-77715EE88A99}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {5FD436B6-61D8-4821-A945-D7E5464B0FE6}
23+
SolutionGuid = {204CCF11-5FB1-4A59-A8B5-B3E39245EBB0}
2424
EndGlobalSection
2525
EndGlobal

‎Chapter22/D_WindowsService/WindowsService/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.EntityFrameworkCore;
62
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.DependencyInjection;
84
using Microsoft.Extensions.Hosting;
95
using Microsoft.Net.Http.Headers;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using System.Threading.Tasks;
1010
using WindowsService.Data;
1111

1212
namespace WindowsService

‎Chapter22/D_WindowsService/WindowsService/Properties/launchSettings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"profiles": {
3-
"SystemdService": {
3+
"WindowsService": {
44
"commandName": "Project",
5+
"dotnetRunMessages": "true",
56
"environmentVariables": {
67
"DOTNET_ENVIRONMENT": "Development"
78
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk.Worker">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<UserSecretsId>dotnet-SystemdService-2AB7067A-5088-4277-B226-DC0A790AB790</UserSecretsId>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.6" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6">
9+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
<PrivateAssets>all</PrivateAssets>
1313
</PackageReference>
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.6" />
15-
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.6" />
16-
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.6" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.0" />
16+
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
1717
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
18-
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
18+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
1919
</ItemGroup>
2020
</Project>

‎Chapter22/D_WindowsService/WindowsService/Worker.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Microsoft.Extensions.Hosting;
3+
using Microsoft.Extensions.Logging;
14
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using System.Threading;
58
using System.Threading.Tasks;
6-
using Microsoft.Extensions.DependencyInjection;
7-
using Microsoft.Extensions.Hosting;
8-
using Microsoft.Extensions.Logging;
99
using WindowsService.Data;
1010

1111
namespace WindowsService
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
4+
VisualStudioVersion = 16.0.30709.132
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuartzHostedService", "QuartzHostedService\QuartzHostedService.csproj", "{BE11F90D-06AE-43E8-94C4-6AE24F518583}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuartzHostedService", "QuartzHostedService\QuartzHostedService.csproj", "{CC26C0D8-977E-4CC6-A611-1F2DE8128A8C}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{CC26C0D8-977E-4CC6-A611-1F2DE8128A8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{CC26C0D8-977E-4CC6-A611-1F2DE8128A8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{CC26C0D8-977E-4CC6-A611-1F2DE8128A8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{CC26C0D8-977E-4CC6-A611-1F2DE8128A8C}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {5FD436B6-61D8-4821-A945-D7E5464B0FE6}
23+
SolutionGuid = {DC1F7272-5AEC-40A6-961D-418930FA1E2A}
2424
EndGlobalSection
2525
EndGlobal

‎Chapter22/E_QuartzHostedService/QuartzHostedService/Program.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.EntityFrameworkCore;
62
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.DependencyInjection;
84
using Microsoft.Extensions.Hosting;
95
using Microsoft.Net.Http.Headers;
106
using Quartz;
117
using QuartzHostedService.Data;
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Threading.Tasks;
1212

1313
namespace QuartzHostedService
1414
{
@@ -42,8 +42,6 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
4242
// Use a Scoped container for creating IJobs
4343
q.UseMicrosoftDependencyInjectionScopedJobFactory();
4444

45-
q.UseSimpleTypeLoader();
46-
4745
// add the job
4846
var jobKey = new JobKey("Update exchange rates");
4947
q.AddJob<UpdateExchangeRatesJob>(opts => opts.WithIdentity(jobKey));
@@ -55,7 +53,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
5553
.RepeatForever())
5654
);
5755
});
58-
services.AddQuartzServer(q => q.WaitForJobsToComplete = true);
56+
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
5957
});
6058
}
6159
}

‎Chapter22/E_QuartzHostedService/QuartzHostedService/Properties/launchSettings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"profiles": {
3-
"SystemdService": {
3+
"QuartzHostedService": {
44
"commandName": "Project",
5+
"dotnetRunMessages": "true",
56
"environmentVariables": {
67
"DOTNET_ENVIRONMENT": "Development"
78
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Worker">
1+
<Project Sdk="Microsoft.NET.Sdk.Worker">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<UserSecretsId>dotnet-SystemdService-2AB7067A-5088-4277-B226-DC0A790AB790</UserSecretsId>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.6" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6">
9+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
<PrivateAssets>all</PrivateAssets>
1313
</PackageReference>
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.6" />
15-
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.6" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
1616
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
17-
<PackageReference Include="Quartz.AspNetCore" Version="3.1.0" />
18-
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
17+
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.2.3" />
18+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
1919
</ItemGroup>
2020
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
4+
VisualStudioVersion = 16.0.30709.132
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuartzClustering", "QuartzClustering\QuartzClustering.csproj", "{BE11F90D-06AE-43E8-94C4-6AE24F518583}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuartzClustering", "QuartzClustering\QuartzClustering.csproj", "{0891DB63-EEFA-4141-B161-F8A6B63B1DB6}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{BE11F90D-06AE-43E8-94C4-6AE24F518583}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{0891DB63-EEFA-4141-B161-F8A6B63B1DB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0891DB63-EEFA-4141-B161-F8A6B63B1DB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0891DB63-EEFA-4141-B161-F8A6B63B1DB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0891DB63-EEFA-4141-B161-F8A6B63B1DB6}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {5FD436B6-61D8-4821-A945-D7E5464B0FE6}
23+
SolutionGuid = {D11C3843-48AF-430A-AC7C-AB33BD9AC8D3}
2424
EndGlobalSection
2525
EndGlobal

‎Chapter22/F_QuartzClustering/QuartzClustering/Program.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.EntityFrameworkCore;
62
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.DependencyInjection;
84
using Microsoft.Extensions.Hosting;
95
using Microsoft.Net.Http.Headers;
106
using Quartz;
117
using QuartzClustering.Data;
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Threading.Tasks;
1212

1313
namespace QuartzClustering
1414
{
@@ -43,8 +43,6 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
4343
// Use a Scoped container for creating IJobs
4444
q.UseMicrosoftDependencyInjectionScopedJobFactory();
4545

46-
q.UseSimpleTypeLoader();
47-
4846
q.UsePersistentStore(s =>
4947
{
5048
s.UseSqlServer(connectionString);
@@ -75,7 +73,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
7573
)
7674
);
7775
});
78-
services.AddQuartzServer(q => q.WaitForJobsToComplete = true);
76+
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
7977
});
8078
}
8179
}

‎Chapter22/F_QuartzClustering/QuartzClustering/Properties/launchSettings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"profiles": {
3-
"SystemdService": {
3+
"QuartzClustering": {
44
"commandName": "Project",
5+
"dotnetRunMessages": "true",
56
"environmentVariables": {
67
"DOTNET_ENVIRONMENT": "Development"
78
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Worker">
1+
<Project Sdk="Microsoft.NET.Sdk.Worker">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<UserSecretsId>dotnet-SystemdService-2AB7067A-5088-4277-B226-DC0A790AB790</UserSecretsId>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<!--<PackageReference Include="Microsoft.Data.Sqlite" Version="3.1.6" />-->
10-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.6" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6">
9+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
10+
<!--<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.0" />-->
11+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
1213
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1314
<PrivateAssets>all</PrivateAssets>
1415
</PackageReference>
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.6" />
16-
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.6" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
1718
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
18-
<PackageReference Include="Quartz.AspNetCore" Version="3.1.0" />
19-
<PackageReference Include="Quartz.Serialization.Json" Version="3.1.0" />
20-
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
19+
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.2.3" />
20+
<PackageReference Include="Quartz.Serialization.Json" Version="3.2.3" />
21+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
2122
</ItemGroup>
2223
</Project>

0 commit comments

Comments
 (0)
Please sign in to comment.