Skip to content

Commit

Permalink
Merge pull request #331 from GeoWerkstatt/dotnet-8
Browse files Browse the repository at this point in the history
Update to .NET 8
  • Loading branch information
domi-b authored Jan 31, 2024
2 parents ede4971 + ec8aa0c commit d2411ff
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>8.0-recommended</AnalysisLevel>
<NoWarn>CS1591,CS8618,CS8620</NoWarn>
<VersionPrefix>1.0</VersionPrefix>
<Product>ews-boda</Product>
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
ARG VERSION
ARG REVISION
Expand Down Expand Up @@ -40,18 +40,20 @@ RUN dotnet publish "EWS.csproj" \
COPY docs/ ./docs/
RUN ~/.dotnet/tools/docfx build -o ${PUBLISH_DIR}/wwwroot/help docs/docfx.json

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS final
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
ENV HOME=/app
ENV TZ=Europe/Zurich
ENV ASPNETCORE_ENVIRONMENT=Production
WORKDIR ${HOME}

EXPOSE 80
EXPOSE 8080

# Set default locale
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

COPY --from=build /app/publish $HOME

USER $APP_UID

ENTRYPOINT ["dotnet", "EWS.dll"]
2 changes: 1 addition & 1 deletion src/Controllers/ExportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public async Task<ContentResult> GetAsync(CancellationToken cancellationToken)
cancellationToken).ConfigureAwait(false);

Response.Headers.ContentDisposition = "attachment; filename=data_export.csv";
return Content(await reader.ReadToEndAsync().ConfigureAwait(false), "text/csv", Encoding.UTF8);
return Content(await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false), "text/csv", Encoding.UTF8);
}
}
8 changes: 6 additions & 2 deletions src/Controllers/StandortController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public async Task<IEnumerable<Standort>> GetAsync(
string? gemeinde = null, string? gbnummer = null, string? bezeichnung = null, DateTime? erstellungsdatum = null, DateTime? mutationsdatum = null)
{
var standorte = Context.Standorte.Include(s => s.Bohrungen).AsQueryable();
#pragma warning disable CA1304 // Specify CultureInfo

#pragma warning disable CA1304 // Specify CultureInfo
#pragma warning disable CA1311 // Specify a culture or use an invariant version
#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
if (!string.IsNullOrEmpty(gemeinde))
{
standorte = standorte.Where(s => s.Gemeinde.ToLower().Contains(gemeinde.ToLower()));
Expand All @@ -36,8 +38,10 @@ public async Task<IEnumerable<Standort>> GetAsync(
if (!string.IsNullOrEmpty(bezeichnung))
{
standorte = standorte.Where(s => s.Bezeichnung.ToLower().Contains(bezeichnung.ToLower()));
#pragma warning restore CA1304 // Specify CultureInfo
}
#pragma warning restore CA1304 // Specify CultureInfo
#pragma warning restore CA1311 // Specify a culture or use an invariant version
#pragma warning restore CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons

if (erstellungsdatum != null)
{
Expand Down
21 changes: 9 additions & 12 deletions src/EWS.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
Expand All @@ -15,17 +15,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NetTopologySuite.IO.GeoJSON4STJ" Version="2.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite" Version="6.0.5" />
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="NetTopologySuite.IO.GeoJSON4STJ" Version="4.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/EwsContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ public static void SeedData(this EwsContext context)
context.SaveChangesWithoutUpdatingChangeInformation();

// Sync all database sequences
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.codetyp', 'codetyp_id'), {codetyp_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.code', 'code_id'), {code_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.codeschicht', 'codeschicht_id'),{codeschicht_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.standort', 'standort_id'),{standort_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.bohrung', 'bohrung_id'),{bohrung_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.bohrprofil', 'bohrprofil_id'),{bohrprofil_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.schicht', 'schicht_id'),{schicht_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.vorkommnis', 'vorkommnis_id'),{vorkommnis_ids - 1})");
context.Database.ExecuteSqlRaw($"SELECT setval(pg_get_serial_sequence('bohrung.user', 'user_id'),{user_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.codetyp', 'codetyp_id'), {codetyp_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.code', 'code_id'), {code_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.codeschicht', 'codeschicht_id'),{codeschicht_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.standort', 'standort_id'),{standort_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.bohrung', 'bohrung_id'),{bohrung_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.bohrprofil', 'bohrprofil_id'),{bohrprofil_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.schicht', 'schicht_id'),{schicht_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.vorkommnis', 'vorkommnis_id'),{vorkommnis_ids - 1})");
context.Database.ExecuteSql($"SELECT setval(pg_get_serial_sequence('bohrung.user', 'user_id'),{user_ids - 1})");

transaction.Commit();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
ValidateAudience = false,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(builder.Configuration["Auth:IssuerSigningKey"])),
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(builder.Configuration["Auth:IssuerSigningKey"]!)),
};
});

Expand Down
16 changes: 8 additions & 8 deletions tests/EWS.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<RootNamespace>EWS</RootNamespace>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<NoWarn>$(NoWarn),CA1001,CA1014,CS8625,CA2000,CA2007,CS8601</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/VersionControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class VersionControllerTest
public void Get()
{
var controller = new VersionController();
Assert.AreEqual("1.0", controller.Get());
StringAssert.StartsWith(controller.Get(), "1.0");
}
}

0 comments on commit d2411ff

Please sign in to comment.