Skip to content

Commit 1102188

Browse files
dotnet 6 upgrade (#1)
1 parent d588eeb commit 1102188

File tree

17 files changed

+164
-275
lines changed

17 files changed

+164
-275
lines changed

.github/workflows/back-end-ci-cd.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v1
2121
with:
22-
dotnet-version: 5.0.101
22+
dotnet-version: 6.0.x
2323
- name: Build
2424
run: dotnet build 'FrontEndBackEndDemo.Api/FrontEndBackEndDemo.Api.csproj' --configuration Release
25+
- name: Publish
26+
run: dotnet publish 'FrontEndBackEndDemo.Api/FrontEndBackEndDemo.Api.csproj' --configuration Release -o 'publish/app'
27+
- name: Docker build
28+
run: docker build -f 'FrontEndBackEndDemo.Api/Dockerfile' -t 45862391/frontendbackenddemo-backend:1.0.2 .
2529

2630
github-docker-push:
2731
if: ${{ github.event_name == 'push' }}
@@ -34,15 +38,15 @@ jobs:
3438
- name: Setup .NET
3539
uses: actions/setup-dotnet@v1
3640
with:
37-
dotnet-version: 5.0.101
41+
dotnet-version: 6.0.x
3842
- name: Publish
3943
run: dotnet publish 'FrontEndBackEndDemo.Api/FrontEndBackEndDemo.Api.csproj' --configuration Release -o 'publish/app'
4044
- name: Docker build
41-
run: docker build -f 'FrontEndBackEndDemo.Api/Dockerfile' -t docker.pkg.github.com/arnab-developer/frontendbackenddemo/backend:1.0.1 .
45+
run: docker build -f 'FrontEndBackEndDemo.Api/Dockerfile' -t docker.pkg.github.com/arnab-developer/frontendbackenddemo/backend:1.0.2 .
4246
- name: Docker push
4347
run: |
4448
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u Arnab-Developer --password-stdin
45-
docker push docker.pkg.github.com/arnab-developer/frontendbackenddemo/backend:1.0.1
49+
docker push docker.pkg.github.com/arnab-developer/frontendbackenddemo/backend:1.0.2
4650
docker logout https://docker.pkg.github.com
4751
4852
dockerhub-push:
@@ -59,13 +63,13 @@ jobs:
5963
- name: Setup .NET
6064
uses: actions/setup-dotnet@v1
6165
with:
62-
dotnet-version: 5.0.101
66+
dotnet-version: 6.0.x
6367
- name: Publish
6468
run: dotnet publish 'FrontEndBackEndDemo.Api/FrontEndBackEndDemo.Api.csproj' --configuration Release -o 'publish/app'
6569
- name: Docker build
66-
run: docker build -f 'FrontEndBackEndDemo.Api/Dockerfile' -t 45862391/frontendbackenddemo-backend:1.0.1 .
70+
run: docker build -f 'FrontEndBackEndDemo.Api/Dockerfile' -t 45862391/frontendbackenddemo-backend:1.0.2 .
6771
- name: Docker push
6872
run: |
6973
echo "${{ secrets.DOCKERHUB_PWD }}" | docker login -u 45862391 --password-stdin
70-
docker push 45862391/frontendbackenddemo-backend:1.0.1
71-
docker logout
74+
docker push 45862391/frontendbackenddemo-backend:1.0.2
75+
docker logout

.github/workflows/front-end-ci-cd.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v1
2121
with:
22-
dotnet-version: 5.0.101
22+
dotnet-version: 6.0.x
2323
- name: Build
2424
run: dotnet build 'FrontEndBackEndDemo.Web/FrontEndBackEndDemo.Web.csproj' --configuration Release
25+
- name: Publish
26+
run: dotnet publish 'FrontEndBackEndDemo.Web/FrontEndBackEndDemo.Web.csproj' --configuration Release -o 'publish/app'
27+
- name: Docker build
28+
run: docker build -f 'FrontEndBackEndDemo.Web/Dockerfile' -t docker.pkg.github.com/arnab-developer/frontendbackenddemo/frontend:1.0.2 .
2529

2630
github-docker-push:
2731
if: ${{ github.event_name == 'push' }}
@@ -34,15 +38,15 @@ jobs:
3438
- name: Setup .NET
3539
uses: actions/setup-dotnet@v1
3640
with:
37-
dotnet-version: 5.0.101
41+
dotnet-version: 6.0.x
3842
- name: Publish
3943
run: dotnet publish 'FrontEndBackEndDemo.Web/FrontEndBackEndDemo.Web.csproj' --configuration Release -o 'publish/app'
4044
- name: Docker build
41-
run: docker build -f 'FrontEndBackEndDemo.Web/Dockerfile' -t docker.pkg.github.com/arnab-developer/frontendbackenddemo/frontend:1.0.1 .
45+
run: docker build -f 'FrontEndBackEndDemo.Web/Dockerfile' -t docker.pkg.github.com/arnab-developer/frontendbackenddemo/frontend:1.0.2 .
4246
- name: Docker push
4347
run: |
4448
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u Arnab-Developer --password-stdin
45-
docker push docker.pkg.github.com/arnab-developer/frontendbackenddemo/frontend:1.0.1
49+
docker push docker.pkg.github.com/arnab-developer/frontendbackenddemo/frontend:1.0.2
4650
docker logout https://docker.pkg.github.com
4751
4852
dockerhub-push:
@@ -59,13 +63,13 @@ jobs:
5963
- name: Setup .NET
6064
uses: actions/setup-dotnet@v1
6165
with:
62-
dotnet-version: 5.0.101
66+
dotnet-version: 6.0.x
6367
- name: Publish
6468
run: dotnet publish 'FrontEndBackEndDemo.Web/FrontEndBackEndDemo.Web.csproj' --configuration Release -o 'publish/app'
6569
- name: Docker build
66-
run: docker build -f 'FrontEndBackEndDemo.Web/Dockerfile' -t 45862391/frontendbackenddemo-frontend:1.0.1 .
70+
run: docker build -f 'FrontEndBackEndDemo.Web/Dockerfile' -t 45862391/frontendbackenddemo-frontend:1.0.2 .
6771
- name: Docker push
6872
run: |
6973
echo "${{ secrets.DOCKERHUB_PWD }}" | docker login -u 45862391 --password-stdin
70-
docker push 45862391/frontendbackenddemo-frontend:1.0.1
74+
docker push 45862391/frontendbackenddemo-frontend:1.0.2
7175
docker logout
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
using Microsoft.AspNetCore.Mvc;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
52

6-
namespace FrontEndBackEndDemo.Api.Controllers
3+
namespace FrontEndBackEndDemo.Api.Controllers;
4+
5+
[ApiController]
6+
[Route("[controller]")]
7+
public class WeatherForecastController : ControllerBase
78
{
8-
[ApiController]
9-
[Route("[controller]")]
10-
public class WeatherForecastController : ControllerBase
9+
private static readonly string[] _summaries = new[]
1110
{
12-
private static readonly string[] _summaries = new[]
13-
{
14-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
15-
};
11+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12+
};
1613

17-
[HttpGet]
18-
public IEnumerable<WeatherForecast> Get()
14+
[HttpGet]
15+
public IEnumerable<WeatherForecast> Get()
16+
{
17+
var rng = new Random();
18+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
1919
{
20-
var rng = new Random();
21-
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
22-
{
23-
Date = DateTime.Now.AddDays(index),
24-
TemperatureC = rng.Next(-20, 55),
25-
Summary = _summaries[rng.Next(_summaries.Length)]
26-
})
27-
.ToArray();
28-
}
20+
Date = DateTime.Now.AddDays(index),
21+
TemperatureC = rng.Next(-20, 55),
22+
Summary = _summaries[rng.Next(_summaries.Length)]
23+
})
24+
.ToArray();
2925
}
30-
}
26+
}

FrontEndBackEndDemo.Api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:5.0
1+
FROM mcr.microsoft.com/dotnet/aspnet:6.0
22
COPY publish/app/ ./app
33
WORKDIR /app
44
ENTRYPOINT ["dotnet", "FrontEndBackEndDemo.Api.dll"]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
6-
<LangVersion>9</LangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
1111
</ItemGroup>
1212

1313
</Project>

FrontEndBackEndDemo.Api/Program.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
using Microsoft.AspNetCore.Hosting;
2-
using Microsoft.Extensions.Hosting;
1+
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
2+
builder.Services.AddEndpointsApiExplorer();
3+
builder.Services.AddSwaggerGen();
4+
builder.Services.AddControllers();
35

4-
namespace FrontEndBackEndDemo.Api
6+
WebApplication app = builder.Build();
7+
if (app.Environment.IsDevelopment())
58
{
6-
public class Program
7-
{
8-
public static void Main(string[] args)
9-
{
10-
CreateHostBuilder(args).Build().Run();
11-
}
12-
13-
public static IHostBuilder CreateHostBuilder(string[] args) =>
14-
Host.CreateDefaultBuilder(args)
15-
.ConfigureWebHostDefaults(webBuilder =>
16-
{
17-
webBuilder.UseStartup<Startup>();
18-
});
19-
}
9+
app.UseSwagger();
10+
app.UseSwaggerUI();
2011
}
12+
app.MapControllers();
13+
14+
app.Run();

FrontEndBackEndDemo.Api/Startup.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
using System;
1+
namespace FrontEndBackEndDemo.Api;
22

3-
namespace FrontEndBackEndDemo.Api
3+
public class WeatherForecast
44
{
5-
public class WeatherForecast
6-
{
7-
public DateTime Date { get; set; }
5+
public DateTime Date { get; set; }
86

9-
public int TemperatureC { get; set; }
7+
public int TemperatureC { get; set; }
108

11-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1210

13-
public string Summary { get; set; }
11+
public string Summary { get; set; }
1412

15-
public WeatherForecast()
16-
{
17-
Summary = string.Empty;
18-
}
13+
public WeatherForecast()
14+
{
15+
Summary = string.Empty;
1916
}
20-
}
17+
}

FrontEndBackEndDemo.Web/Controllers/HomeController.cs

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,48 @@
22
using FrontEndBackEndDemo.Web.Options;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.Options;
5-
using System.Collections.Generic;
65
using System.Diagnostics;
7-
using System.IO;
8-
using System.Net.Http;
96
using System.Text.Json;
10-
using System.Threading.Tasks;
117

12-
namespace FrontEndBackEndDemo.Web.Controllers
8+
namespace FrontEndBackEndDemo.Web.Controllers;
9+
10+
public class HomeController : Controller
1311
{
14-
public class HomeController : Controller
15-
{
16-
private readonly IHttpClientFactory _httpClientFactory;
17-
private readonly IOptionsMonitor<BackEndOptions> _backEndOptionOptionsAccessor;
12+
private readonly IHttpClientFactory _httpClientFactory;
13+
private readonly IOptionsMonitor<BackEndOptions> _backEndOptionOptionsAccessor;
1814

19-
public HomeController(
20-
IHttpClientFactory httpClientFactory,
21-
IOptionsMonitor<BackEndOptions> backEndOptionOptionsAccessor)
22-
{
23-
_httpClientFactory = httpClientFactory;
24-
_backEndOptionOptionsAccessor = backEndOptionOptionsAccessor;
25-
}
15+
public HomeController(
16+
IHttpClientFactory httpClientFactory,
17+
IOptionsMonitor<BackEndOptions> backEndOptionOptionsAccessor)
18+
{
19+
_httpClientFactory = httpClientFactory;
20+
_backEndOptionOptionsAccessor = backEndOptionOptionsAccessor;
21+
}
2622

27-
public async Task<IActionResult> Index()
23+
public async Task<IActionResult> Index()
24+
{
25+
HttpClient httpClient = _httpClientFactory.CreateClient();
26+
HttpResponseMessage backEndApiResponseMessage = await httpClient.GetAsync(
27+
_backEndOptionOptionsAccessor.CurrentValue.BackEndApiEndPoint);
28+
if (backEndApiResponseMessage.IsSuccessStatusCode)
2829
{
29-
HttpClient httpClient = _httpClientFactory.CreateClient();
30-
HttpResponseMessage backEndApiResponseMessage = await httpClient.GetAsync(
31-
_backEndOptionOptionsAccessor.CurrentValue.BackEndApiEndPoint);
32-
if (backEndApiResponseMessage.IsSuccessStatusCode)
33-
{
34-
using Stream backEndApiResponseStream =
35-
await backEndApiResponseMessage.Content.ReadAsStreamAsync();
36-
IEnumerable<WeatherForecast>? weatherForecast =
37-
await JsonSerializer.DeserializeAsync<IEnumerable<WeatherForecast>>(backEndApiResponseStream);
38-
return View(weatherForecast);
39-
}
40-
return NotFound();
30+
using Stream backEndApiResponseStream =
31+
await backEndApiResponseMessage.Content.ReadAsStreamAsync();
32+
IEnumerable<WeatherForecast>? weatherForecast =
33+
await JsonSerializer.DeserializeAsync<IEnumerable<WeatherForecast>>(backEndApiResponseStream);
34+
return View(weatherForecast);
4135
}
36+
return NotFound();
37+
}
4238

43-
public IActionResult Privacy()
44-
{
45-
return View();
46-
}
39+
public IActionResult Privacy()
40+
{
41+
return View();
42+
}
4743

48-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
49-
public IActionResult Error()
50-
{
51-
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
52-
}
44+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
45+
public IActionResult Error()
46+
{
47+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
5348
}
54-
}
49+
}

FrontEndBackEndDemo.Web/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:5.0
1+
FROM mcr.microsoft.com/dotnet/aspnet:6.0
22
COPY publish/app/ ./app
33
WORKDIR /app
44
ENTRYPOINT ["dotnet", "FrontEndBackEndDemo.Web.dll"]

0 commit comments

Comments
 (0)