Skip to content

Commit 585559c

Browse files
Merge pull request #175 from FromDoppler/net7
Update to .NET 7
2 parents a000311 + 13fb092 commit 585559c

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/Doppler.HelloMicroservice/bin/Debug/net6.0/Doppler.HelloMicroservice.dll",
13+
"program": "${workspaceFolder}/Doppler.HelloMicroservice/bin/Debug/net7.0/Doppler.HelloMicroservice.dll",
1414
"args": [],
1515
"cwd": "${workspaceFolder}/Doppler.HelloMicroservice",
1616
"stopAtEntry": false,

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WORKDIR /src
1010
COPY ./*.sh ./
1111
RUN shellcheck -e SC1091,SC1090 ./*.sh
1212

13-
FROM mcr.microsoft.com/dotnet/sdk:6.0.406-bullseye-slim AS restore
13+
FROM mcr.microsoft.com/dotnet/sdk:7.0.103-bullseye-slim AS restore
1414
WORKDIR /src
1515
COPY ./*.sln ./
1616
COPY */*.csproj ./
@@ -29,7 +29,7 @@ RUN dotnet test
2929
FROM build AS publish
3030
RUN dotnet publish "./Doppler.HelloMicroservice/Doppler.HelloMicroservice.csproj" -c Release -o /app/publish
3131

32-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.14-bullseye-slim AS final
32+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.3-bullseye-slim AS final
3333
# We need these changes in openssl.cnf to access to our SQL Server instances in QA and INT environments
3434
# See more information in https://stackoverflow.com/questions/56473656/cant-connect-to-sql-server-named-instance-from-asp-net-core-running-in-docker/59391426#59391426
3535
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf \

Doppler.HelloMicroservice.Test/Doppler.HelloMicroservice.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<RootNamespace>Doppler.HelloMicroservice</RootNamespace>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.14" />
11+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.3" />
1212
<PackageReference Include="Moq" Version="4.18.4" />
1313
<PackageReference Include="xunit" Version="2.4.2" />
1414
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

Doppler.HelloMicroservice/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.14-bullseye-slim AS base
3+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.3-bullseye-slim AS base
44
WORKDIR /app
55
EXPOSE 80
66

7-
FROM mcr.microsoft.com/dotnet/sdk:6.0.406-bullseye-slim AS build
7+
FROM mcr.microsoft.com/dotnet/sdk:7.0.103-bullseye-slim AS build
88
WORKDIR /src
99
COPY ["Doppler.HelloMicroservice/Doppler.HelloMicroservice.csproj", "Doppler.HelloMicroservice/"]
1010
RUN dotnet restore "Doppler.HelloMicroservice/Doppler.HelloMicroservice.csproj"

Doppler.HelloMicroservice/Doppler.HelloMicroservice.csproj

Lines changed: 2 additions & 2 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>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="6.5.1" />
10-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.14" />
10+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.3" />
1111
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
1212
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
1313
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />

Doppler.HelloMicroservice/Startup.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5-
using Hellang.Middleware.ProblemDetails;
65
using Microsoft.AspNetCore.Builder;
76
using Microsoft.AspNetCore.Hosting;
87
using Microsoft.Extensions.Configuration;
@@ -23,7 +22,11 @@ public Startup(IConfiguration configuration)
2322
// This method gets called by the runtime. Use this method to add services to the container.
2423
public void ConfigureServices(IServiceCollection services)
2524
{
26-
services.AddProblemDetails();
25+
// Explicitly using Hellang because services.AddProblemDetails() generates an ambiguity
26+
// between Microsoft.AspNetCore.Http.Extensions.ProblemDetailsServiceCollectionExtensions
27+
// and Hellang.Middleware.ProblemDetails.ProblemDetailsExtensions
28+
// TODO: consider replace Hellang by out of the box alternative (but it is not working fine right now)
29+
Hellang.Middleware.ProblemDetails.ProblemDetailsExtensions.AddProblemDetails(services);
2730
services.AddDopplerSecurity();
2831
services.AddControllers();
2932
services.AddCors();
@@ -64,7 +67,7 @@ public void ConfigureServices(IServiceCollection services)
6467
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
6568
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
6669
{
67-
app.UseProblemDetails();
70+
Hellang.Middleware.ProblemDetails.ProblemDetailsExtensions.UseProblemDetails(app);
6871

6972
app.UseSwagger();
7073
app.UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "Doppler.HelloMicroservice v1"));

0 commit comments

Comments
 (0)