From 9ccc42f556d57d421a9dc6aab5ec489fcf73dfb2 Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Tue, 21 Nov 2023 14:11:17 +0900 Subject: [PATCH] Bump .NET 8.0 (#5479) --- .../BTCPayServer.Abstractions.csproj | 8 ++++---- .../Contracts/BaseDbContextFactory.cs | 1 + BTCPayServer.Abstractions/Form/Form.cs | 1 - BTCPayServer.Client/BTCPayServer.Client.csproj | 2 +- BTCPayServer.Data/BTCPayServer.Data.csproj | 6 +++--- BTCPayServer.Data/Data/AddressInvoiceData.cs | 1 + BTCPayServer.Data/Data/RefundData.cs | 1 + .../BTCPayServer.PluginPacker.csproj | 2 +- BTCPayServer.Rating/BTCPayServer.Rating.csproj | 4 ++-- BTCPayServer.Tests/BTCPayServer.Tests.csproj | 8 ++++---- BTCPayServer.Tests/Dockerfile | 2 +- BTCPayServer.Tests/ThirdPartyTests.cs | 2 +- BTCPayServer.Tests/UnitTest1.cs | 2 +- BTCPayServer.Tests/docker-compose.altcoins.yml | 2 +- BTCPayServer.Tests/docker-compose.yml | 2 +- BTCPayServer/BTCPayServer.csproj | 14 +++++++------- BTCPayServer/Controllers/UIInvoiceController.UI.cs | 1 + BTCPayServer/Hosting/Startup.cs | 9 --------- .../Hosting/ToPostgresMigrationStartupTask.cs | 8 ++++++-- BTCPayServer/Views/Shared/LayoutFoot.cshtml | 2 +- Build/Common.csproj | 4 ++-- amd64.Dockerfile | 4 ++-- arm32v7.Dockerfile | 4 ++-- arm64v8.Dockerfile | 4 ++-- 24 files changed, 46 insertions(+), 48 deletions(-) diff --git a/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj b/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj index e5c5406d0..e298d82dd 100644 --- a/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj +++ b/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj @@ -32,10 +32,10 @@ - - - - + + + + diff --git a/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs b/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs index 96006b735..d58cc4332 100644 --- a/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs +++ b/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs @@ -84,6 +84,7 @@ namespace BTCPayServer.Abstractions.Contracts .UseNpgsql(_options.Value.ConnectionString, o => { o.EnableRetryOnFailure(10); + o.SetPostgresVersion(12, 0); if (!string.IsNullOrEmpty(_schemaPrefix)) { o.MigrationsHistoryTable(_schemaPrefix); diff --git a/BTCPayServer.Abstractions/Form/Form.cs b/BTCPayServer.Abstractions/Form/Form.cs index 0f91954e2..f6e46af15 100644 --- a/BTCPayServer.Abstractions/Form/Form.cs +++ b/BTCPayServer.Abstractions/Form/Form.cs @@ -5,7 +5,6 @@ using System.Reflection; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; -using Npgsql.Internal.TypeHandlers.GeometricHandlers; namespace BTCPayServer.Abstractions.Form; diff --git a/BTCPayServer.Client/BTCPayServer.Client.csproj b/BTCPayServer.Client/BTCPayServer.Client.csproj index e91cf308a..60a9ee495 100644 --- a/BTCPayServer.Client/BTCPayServer.Client.csproj +++ b/BTCPayServer.Client/BTCPayServer.Client.csproj @@ -31,7 +31,7 @@ - + diff --git a/BTCPayServer.Data/BTCPayServer.Data.csproj b/BTCPayServer.Data/BTCPayServer.Data.csproj index 856815148..e497e8e4f 100644 --- a/BTCPayServer.Data/BTCPayServer.Data.csproj +++ b/BTCPayServer.Data/BTCPayServer.Data.csproj @@ -1,13 +1,13 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/BTCPayServer.Data/Data/AddressInvoiceData.cs b/BTCPayServer.Data/Data/AddressInvoiceData.cs index 0d62df7b3..8e08e82a1 100644 --- a/BTCPayServer.Data/Data/AddressInvoiceData.cs +++ b/BTCPayServer.Data/Data/AddressInvoiceData.cs @@ -1,5 +1,6 @@ using System; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; namespace BTCPayServer.Data { diff --git a/BTCPayServer.Data/Data/RefundData.cs b/BTCPayServer.Data/Data/RefundData.cs index dafbe5bf9..8aa6c402b 100644 --- a/BTCPayServer.Data/Data/RefundData.cs +++ b/BTCPayServer.Data/Data/RefundData.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; namespace BTCPayServer.Data { diff --git a/BTCPayServer.PluginPacker/BTCPayServer.PluginPacker.csproj b/BTCPayServer.PluginPacker/BTCPayServer.PluginPacker.csproj index c637eaf00..4c531e494 100644 --- a/BTCPayServer.PluginPacker/BTCPayServer.PluginPacker.csproj +++ b/BTCPayServer.PluginPacker/BTCPayServer.PluginPacker.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 1.0.0.0 true btcpay-plugin diff --git a/BTCPayServer.Rating/BTCPayServer.Rating.csproj b/BTCPayServer.Rating/BTCPayServer.Rating.csproj index 5ccd765da..2165a3708 100644 --- a/BTCPayServer.Rating/BTCPayServer.Rating.csproj +++ b/BTCPayServer.Rating/BTCPayServer.Rating.csproj @@ -4,9 +4,9 @@ - + - + diff --git a/BTCPayServer.Tests/BTCPayServer.Tests.csproj b/BTCPayServer.Tests/BTCPayServer.Tests.csproj index 558d28098..80c1f8114 100644 --- a/BTCPayServer.Tests/BTCPayServer.Tests.csproj +++ b/BTCPayServer.Tests/BTCPayServer.Tests.csproj @@ -19,13 +19,13 @@ - + - - - + + + all runtime; build; native; contentfiles; analyzers diff --git a/BTCPayServer.Tests/Dockerfile b/BTCPayServer.Tests/Dockerfile index ec9cea303..04e2e763e 100644 --- a/BTCPayServer.Tests/Dockerfile +++ b/BTCPayServer.Tests/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.401-bullseye-slim AS builder +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim AS builder RUN apt-get update && apt-get install -y --no-install-recommends chromium-driver \ && rm -rf /var/lib/apt/lists/* diff --git a/BTCPayServer.Tests/ThirdPartyTests.cs b/BTCPayServer.Tests/ThirdPartyTests.cs index a699c7f9a..2b0c6350f 100644 --- a/BTCPayServer.Tests/ThirdPartyTests.cs +++ b/BTCPayServer.Tests/ThirdPartyTests.cs @@ -268,7 +268,7 @@ retry: } catch (Exception ex) { - var details = ex is EqualException ? (ex as EqualException).Actual : ex.Message; + var details = ex.Message; TestLogs.LogInformation($"FAILED: {url} ({file}) {details}"); throw; diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 46d5dfe1c..ec2f43558 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -269,7 +269,7 @@ namespace BTCPayServer.Tests } catch (Exception ex) { - var details = ex is EqualException ? (ex as EqualException).Actual : ex.Message; + var details = ex.Message; TestLogs.LogInformation($"FAILED: {url} ({file}) {details}"); throw; diff --git a/BTCPayServer.Tests/docker-compose.altcoins.yml b/BTCPayServer.Tests/docker-compose.altcoins.yml index 1cd3fc5e4..625835aa2 100644 --- a/BTCPayServer.Tests/docker-compose.altcoins.yml +++ b/BTCPayServer.Tests/docker-compose.altcoins.yml @@ -99,7 +99,7 @@ services: custom: nbxplorer: - image: nicolasdorier/nbxplorer:2.3.66 + image: nicolasdorier/nbxplorer:2.4.0 restart: unless-stopped ports: - "32838:32838" diff --git a/BTCPayServer.Tests/docker-compose.yml b/BTCPayServer.Tests/docker-compose.yml index 5b6cdb56a..05503ab70 100644 --- a/BTCPayServer.Tests/docker-compose.yml +++ b/BTCPayServer.Tests/docker-compose.yml @@ -96,7 +96,7 @@ services: custom: nbxplorer: - image: nicolasdorier/nbxplorer:2.3.66 + image: nicolasdorier/nbxplorer:2.4.0 restart: unless-stopped ports: - "32838:32838" diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 49ad44e4f..e6d0555e9 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -50,22 +50,22 @@ - + - + - - - + + + @@ -75,8 +75,8 @@ - - + + diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index 6f2eb46dc..9a8ba6531 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -550,6 +550,7 @@ namespace BTCPayServer.Controllers Html = "Refund successfully created!
Share the link to this page with a customer.
The customer needs to enter their address and claim the refund.
Once a customer claims the refund, you will get a notification and would need to approve and initiate it from your Store > Payouts.", Severity = StatusMessageModel.StatusSeverity.Success }); + ctx.Refunds.Add(new RefundData { InvoiceDataId = invoice.Id, diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index a75e84a50..0bcf00d08 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -273,15 +273,6 @@ namespace BTCPayServer.Hosting app.UseRouting(); app.UseCors(); - - // HACK: Make blazor js available on: ~/_blazorfiles/_framework/blazor.server.js - // Workaround this bug https://github.com/dotnet/aspnetcore/issues/19578 - app.UseStaticFiles(new StaticFileOptions() - { - RequestPath = "/_blazorfiles", - FileProvider = new ManifestEmbeddedFileProvider(typeof(ComponentServiceCollectionExtensions).Assembly), - OnPrepareResponse = LongCache - }); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = LongCache diff --git a/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs b/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs index 4d63c7ef4..4c594941b 100644 --- a/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs +++ b/BTCPayServer/Hosting/ToPostgresMigrationStartupTask.cs @@ -173,7 +173,11 @@ namespace BTCPayServer.Hosting return; { var postgres = new NpgsqlConnectionStringBuilder(p); - using var postgresContext = new ApplicationDbContext(new DbContextOptionsBuilder().UseNpgsql(p, o => o.CommandTimeout(60 * 60 * 10)).Options); + using var postgresContext = new ApplicationDbContext(new DbContextOptionsBuilder().UseNpgsql(p, o => + { + o.CommandTimeout(60 * 60 * 10); + o.SetPostgresVersion(12, 0); + }).Options); string? state; try { @@ -212,7 +216,7 @@ namespace BTCPayServer.Hosting foreach (var t in postgresContext.Model.GetRelationalModel().Tables.OrderByTopology()) { var typeMapping = t.EntityTypeMappings.Single(); - var query = (IQueryable)otherContext.GetType().GetMethod("Set", new Type[0])!.MakeGenericMethod(typeMapping.EntityType.ClrType).Invoke(otherContext, null)!; + var query = (IQueryable)otherContext.GetType().GetMethod("Set", new Type[0])!.MakeGenericMethod(typeMapping.TypeBase.ClrType).Invoke(otherContext, null)!; if (t.Name == "WebhookDeliveries" || t.Name == "InvoiceWebhookDeliveries" || t.Name == "StoreRoles") diff --git a/BTCPayServer/Views/Shared/LayoutFoot.cshtml b/BTCPayServer/Views/Shared/LayoutFoot.cshtml index a377f3959..31b39df10 100644 --- a/BTCPayServer/Views/Shared/LayoutFoot.cshtml +++ b/BTCPayServer/Views/Shared/LayoutFoot.cshtml @@ -6,6 +6,6 @@ @if (User.Identity.IsAuthenticated && ViewData.IsBlazorAllowed()) { - + } diff --git a/Build/Common.csproj b/Build/Common.csproj index 5eff5c831..8cf952962 100644 --- a/Build/Common.csproj +++ b/Build/Common.csproj @@ -1,8 +1,8 @@ - net6.0 + net8.0 $(TargetFrameworkOverride) - NU1701,CA1816,CA1308,CA1810,CA2208,CA1303,CA2000,CA2016,CA1835,CA2249,CA9998,CA1704 + NU1701,CA1816,CA1308,CA1810,CA2208,CA1303,CA2000,CA2016,CA1835,CA2249,CA9998,CA1704;CS8981 10.0 True 6.0 diff --git a/amd64.Dockerfile b/amd64.Dockerfile index ad65e89d6..9c5f0b171 100644 --- a/amd64.Dockerfile +++ b/amd64.Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.401-bullseye-slim AS builder +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim AS builder ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 WORKDIR /source COPY nuget.config nuget.config @@ -21,7 +21,7 @@ ARG CONFIGURATION_NAME=Release ARG GIT_COMMIT RUN cd BTCPayServer && dotnet publish -p:GitCommit=${GIT_COMMIT} --output /app/ --configuration ${CONFIGURATION_NAME} -FROM mcr.microsoft.com/dotnet/aspnet:6.0.9-bullseye-slim +FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim RUN apt-get update && apt-get install -y --no-install-recommends iproute2 openssh-client \ && rm -rf /var/lib/apt/lists/* diff --git a/arm32v7.Dockerfile b/arm32v7.Dockerfile index 84aefb862..f2a046853 100644 --- a/arm32v7.Dockerfile +++ b/arm32v7.Dockerfile @@ -1,5 +1,5 @@ # Note that we are using buster rather than bullseye. Somehow, raspberry pi 4 doesn't like bullseye. -FROM mcr.microsoft.com/dotnet/sdk:6.0.401-bullseye-slim AS builder +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim AS builder ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 RUN apt-get update \ && apt-get install -qq --no-install-recommends qemu qemu-user-static qemu-user binfmt-support @@ -26,7 +26,7 @@ ARG GIT_COMMIT RUN cd BTCPayServer && dotnet publish -p:GitCommit=${GIT_COMMIT} --output /app/ --configuration ${CONFIGURATION_NAME} # Note that we are using buster rather than bullseye. Somehow, raspberry pi 4 doesn't like bullseye. -FROM mcr.microsoft.com/dotnet/aspnet:6.0.9-bullseye-slim-arm32v7 +FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim-arm32v7 COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static RUN apt-get update && apt-get install -y --no-install-recommends iproute2 openssh-client \ && rm -rf /var/lib/apt/lists/* diff --git a/arm64v8.Dockerfile b/arm64v8.Dockerfile index e057b78dc..5ae37cd67 100644 --- a/arm64v8.Dockerfile +++ b/arm64v8.Dockerfile @@ -1,5 +1,5 @@ # This is a manifest image, will pull the image with the same arch as the builder machine -FROM mcr.microsoft.com/dotnet/sdk:6.0.401-bullseye-slim AS builder +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim AS builder ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 ENV LC_ALL en_US.UTF-8 RUN apt-get update \ @@ -27,7 +27,7 @@ ARG GIT_COMMIT RUN cd BTCPayServer && dotnet publish -p:GitCommit=${GIT_COMMIT} --output /app/ --configuration ${CONFIGURATION_NAME} # Force the builder machine to take make an arm runtime image. This is fine as long as the builder does not run any program -FROM mcr.microsoft.com/dotnet/aspnet:6.0.9-bullseye-slim-arm64v8 +FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim-arm64v8 COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static RUN apt-get update && apt-get install -y --no-install-recommends iproute2 openssh-client \ && rm -rf /var/lib/apt/lists/*