From e84a621ea70f8bf187bb42896ba8b7b8df49c0ae Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 26 Jul 2023 00:10:46 -0400 Subject: [PATCH] Migrate to .NET 8 Preview - Update Nuget packages to preview - Update documentation refs - Update CI dotnet version - Update redistributable - Update winget and deb dependencies - Update base docker images - Remove unnecessary console `PropertyGroup`s - Modify CI to be ODR for the dotnet version - Fix upgrade `#error`s - Http2 never worked and now throws a warning. Remove it - Remove workaround for SqlClient breaking change - Minor return signature optimization in ProcessExecutor - Config version -> 5.0.0 - Core version -> 6.0.0 --- .github/CONTRIBUTING.md | 2 +- .github/workflows/ci-pipeline.yml | 28 +++++++-------- README.md | 8 ++--- build/Dockerfile | 4 +-- build/Version.props | 8 ++--- build/package/deb/build_package.sh | 2 +- build/package/deb/debian/control | 4 +-- .../manifest/Tgstation.Server.installer.yaml | 2 +- .../Tgstation.Server.Host.Console.csproj | 13 +------ .../Tgstation.Server.Host.Service.csproj | 8 ++--- .../Tgstation.Server.Host.Watchdog.csproj | 2 +- .../Watchdog.cs | 2 +- .../Components/README.md | 2 +- .../Database/SqlServerDatabaseContext.cs | 18 +--------- .../IO/DefaultIOManager.cs | 4 +-- src/Tgstation.Server.Host/README.md | 4 +-- src/Tgstation.Server.Host/ServerFactory.cs | 4 +-- .../Setup/SetupWizard.cs | 7 ++-- .../System/ProcessExecutor.cs | 15 ++++---- .../System/SystemDManager.cs | 2 +- .../Tgstation.Server.Host.csproj | 20 +++++------ src/Tgstation.Server.Host/Utils/README.md | 2 +- .../Setup/TestSetupWizard.cs | 2 ++ .../Utils/TestAsyncDelayer.cs | 4 +-- tools/Tgstation.Server.Migrator/Program.cs | 14 ++++---- .../RuntimeDistributableAttribute.cs | 34 +++++++++++++++++++ .../Tgstation.Server.Migrator.csproj | 17 ++++++++-- 27 files changed, 126 insertions(+), 106 deletions(-) create mode 100644 tools/Tgstation.Server.Migrator/Properties/RuntimeDistributableAttribute.cs diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d8b62ead67..2cedb62bfd 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -34,7 +34,7 @@ You can of course, as always, ask for help at [#coderbus](irc://irc.rizon.net/co ### Development Environment -You need the .NET 6.0 SDK and npm>=v5.7 (in your PATH) to compile the server. +You need the .NET 8.0 SDK and npm>=v5.7 (in your PATH) to compile the server. The recommended IDE is Visual Studio 2022 or VSCode. diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index c6b420c33c..4428c8d513 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -38,7 +38,7 @@ on: - V6 env: - TGS_DOTNET_VERSION: 6.0.x + TGS_DOTNET_VERSION: 8.0.x TGS_TEST_GITHUB_TOKEN: ${{ secrets.LIVE_TESTS_TOKEN }} TGS_RELEASE_NOTES_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} WINGET_PUSH_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} @@ -246,7 +246,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Checkout (Branch) uses: actions/checkout@v3 @@ -289,7 +289,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Checkout (Branch) uses: actions/checkout@v3 @@ -338,7 +338,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Set TGS_TEST_DUMP_API_SPEC if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'SqlServer' }} @@ -534,7 +534,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Set Sqlite Connection Info if: ${{ matrix.database-type == 'Sqlite' }} @@ -933,15 +933,15 @@ jobs: echo ${{ secrets.PACKAGING_PRIVATE_KEY_PASSPHRASE }} | gpg --batch --yes --passphrase-fd 0 --import private.pgp rm private.pgp - - name: Install dotnet-sdk-6.0 + - name: Install dotnet-sdk system package run: | sudo apt-get update - sudo apt-get install -y dotnet-sdk-6.0 + sudo apt-get install -y dotnet-sdk-${{ env.TGS_DOTNET_VERSION }} - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Override /usr/bin/dotnet run: | @@ -1027,7 +1027,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Checkout (Branch) uses: actions/checkout@v3 @@ -1152,7 +1152,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Retrieve Latest winget-pkgs PULL_REQUEST_TEMPLATE commit SHA from GitHub API id: get-sha @@ -1291,7 +1291,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Checkout uses: actions/checkout@v3 @@ -1329,7 +1329,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Checkout uses: actions/checkout@v3 @@ -1352,7 +1352,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Checkout uses: actions/checkout@v3 @@ -1590,7 +1590,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ env.TGS_DOTNET_VERSION }} + dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.x' - name: Install winget uses: Cyberboss/install-winget@v1 diff --git a/README.md b/README.md index ab758a5b36..63215614b9 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Note: The `winget` package is submitted to Microsoft for approval once TGS relea ##### Manual -If you don't have it installed already, download and install the [ASP .NET Core Runtime Hosting Bundle (>= v6.0)](https://dotnet.microsoft.com/download/dotnet/6.0). Ensure that the `dotnet` executable file is in your system's `PATH` variable (or that of the user's that will be running the server). You can test this by opening a command prompt and running `dotnet --list-runtimes`. +If you don't have it installed already, download and install the [ASP .NET Core Runtime Hosting Bundle (>= v8.0)](https://dotnet.microsoft.com/download/dotnet/8.0). Ensure that the `dotnet` executable file is in your system's `PATH` variable (or that of the user's that will be running the server). You can test this by opening a command prompt and running `dotnet --list-runtimes`. [Download the latest release .zip](https://github.com/tgstation/tgstation-server/releases/latest). Typically, you want the `ServerService.zip` package in order to run TGS as a Windows service. Choose `ServerConsole.zip` if you prefer to use a command line daemon. @@ -119,7 +119,7 @@ sudo dpkg --add-architecture i386 \ ##### Debian -The `aspnetcore-runtime-6.0` package isn't yet available on mainline Debian and must be [installed from Microsoft](https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian) first. Use the following one-liner to add their packages repository. +The `aspnetcore-runtime-8.0` package isn't yet available on mainline Debian and must be [installed from Microsoft](https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian) first. Use the following one-liner to add their packages repository. ```sh curl -L https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -o packages-microsoft-prod.deb \ @@ -135,7 +135,7 @@ _Support for more distros coming soon_ The following dependencies are required. -- aspnetcore-runtime-6.0 (Note, not all supported distros have this package, see the links above for official Microsoft installation instructions) +- aspnetcore-runtime-8.0 (Note, not all supported distros have this package, see the links above for official Microsoft installation instructions) - libc6-i386 - libstdc++6:i386 - gcc-multilib (Only on 64-bit systems) @@ -197,7 +197,7 @@ There are 3 primary supported ways to configure TGS: - Set environment variables in the form `Section__Subsection=value` or `Section__ArraySubsection__0=value` for arrays. - Set command line arguments in the form `--Section:Subsection=value` or `--Section:ArraySubsection:0=value` for arrays. -The latter two are not recommended as they cannot be dynamically changed at runtime. See more on ASP.NET core configuration [here](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0). +The latter two are not recommended as they cannot be dynamically changed at runtime. See more on ASP.NET core configuration [here](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0). #### Manual Configuration diff --git a/build/Dockerfile b/build/Dockerfile index f1f70e95b3..7985eb8c9a 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build # install node and npm # replace shell with bash so we can source files @@ -63,7 +63,7 @@ RUN dotnet publish -c Release -o /app WORKDIR /repo/src/Tgstation.Server.Host RUN dotnet publish -c Release -o /app/lib/Default && mv /app/lib/Default/appsettings* /app -FROM mcr.microsoft.com/dotnet/aspnet:6.0-bookworm-slim +FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim #needed for byond RUN apt-get update \ diff --git a/build/Version.props b/build/Version.props index 9a9b414cfe..d1fc8f38c3 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,8 +3,8 @@ - 5.14.0 - 4.7.1 + 6.0.0 + 5.0.0 9.11.0 6.0.0 11.0.0 @@ -15,9 +15,9 @@ 1.2.1 1.0.2 netstandard2.0 - 6 + 8 - https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/6.0.20/dotnet-hosting-6.0.20-win.exe + https://download.visualstudio.microsoft.com/download/pr/e5db48f5-99c6-42ca-804a-85b89ae09671/b5594181b347a9a77246e3645916bd0e/dotnet-hosting-8.0.0-preview.6.23329.11-win.exe 11.0.2 https://ftp.osuosl.org/pub/mariadb/mariadb-11.0.2/winx64-packages/mariadb-11.0.2-winx64.msi diff --git a/build/package/deb/build_package.sh b/build/package/deb/build_package.sh index 54063487dc..2f81abb1e0 100755 --- a/build/package/deb/build_package.sh +++ b/build/package/deb/build_package.sh @@ -8,7 +8,7 @@ set -x dpkg --add-architecture i386 apt-get update -apt-get install -y npm dotnet-sdk-6.0 build-essential binutils lintian debhelper dh-make devscripts xmlstarlet # needs cleanup probably, SO copypasta +apt-get install -y npm dotnet-sdk-8.0 build-essential binutils lintian debhelper dh-make devscripts xmlstarlet # needs cleanup probably, SO copypasta CURRENT_COMMIT=$(git rev-parse HEAD) diff --git a/build/package/deb/debian/control b/build/package/deb/debian/control index a4e47829c7..ee30543ecf 100644 --- a/build/package/deb/debian/control +++ b/build/package/deb/debian/control @@ -5,7 +5,7 @@ Maintainer: Jordan Dominion Rules-Requires-Root: no Build-Depends: debhelper-compat (= 13), - dotnet-sdk-6.0, + dotnet-sdk-8.0, npm, Standards-Version: 4.6.2 Homepage: https://tgstation.github.io/tgstation-server @@ -16,7 +16,7 @@ Package: tgstation-server Architecture: any Depends: ${misc:Depends}, - aspnetcore-runtime-6.0, + aspnetcore-runtime-8.0, libc6-i386, libstdc++6:i386 [amd64], libstdc++6 [i386], diff --git a/build/package/winget/manifest/Tgstation.Server.installer.yaml b/build/package/winget/manifest/Tgstation.Server.installer.yaml index f160b69783..7aa187b1bf 100644 --- a/build/package/winget/manifest/Tgstation.Server.installer.yaml +++ b/build/package/winget/manifest/Tgstation.Server.installer.yaml @@ -25,7 +25,7 @@ Installers: Publisher: /tg/station 13 Dependencies: PackageDependencies: - - PackageIdentifier: Microsoft.DotNet.HostingBundle.6 + - PackageIdentifier: Microsoft.DotNet.HostingBundle.8 ReleaseDate: 2023-06-24 # Do not change. Set before publish by push_manifest.ps1 ManifestType: installer ManifestVersion: 1.4.0 diff --git a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj index 7a85df7ea4..ebe2348e40 100644 --- a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj +++ b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj @@ -9,20 +9,9 @@ ../../build/uac_elevation_manifest.xml - - true - - bin\Release\net6.0\Tgstation.Server.Host.Console.xml - - - - 1701;1702;SA1652 - bin\Debug\net6.0\Tgstation.Server.Host.Console.xml - - - + diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj index 0186298b28..1e102db995 100644 --- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj +++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj @@ -19,15 +19,15 @@ - + - + - + - + diff --git a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj index 4cda1e51b1..bfd4955b3b 100644 --- a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj +++ b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs index 21d60f5203..02b25a0726 100644 --- a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs @@ -82,7 +82,7 @@ namespace Tgstation.Server.Host.Watchdog Directory.Delete(assemblyStoragePath, true); Directory.CreateDirectory(defaultAssemblyPath); - var sourcePath = "../../../../Tgstation.Server.Host/bin/Debug/net6.0"; + var sourcePath = "../../../../Tgstation.Server.Host/bin/Debug/net8.0"; foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) Directory.CreateDirectory(dirPath.Replace(sourcePath, defaultAssemblyPath, StringComparison.Ordinal)); diff --git a/src/Tgstation.Server.Host/Components/README.md b/src/Tgstation.Server.Host/Components/README.md index e13f2a3dfb..2106f47dd7 100644 --- a/src/Tgstation.Server.Host/Components/README.md +++ b/src/Tgstation.Server.Host/Components/README.md @@ -20,4 +20,4 @@ While the database represents stored instance data, in component code an instanc `IInstance`s ([implementation](./Instance.cs)) are created via the [IInstanceFactory](./IInstanceFactory.cs) ([implementation](./InstanceFactory.cs)) and are generally controlled via the [IInstanceOperations](./IInstanceOperations.cs) interface (implemented in the `InstanceManager`). -Many classes in here implement [IHostedService](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-6.0&tabs=visual-studio), `InstanceManager` being the only one that is called by the ASP.NET runtime. In the case of instances `StartAsync()` is called when an `Instance` is being brought online (from server startup or user request). The `Instance` handles calling `StartAsync()` on its various subcomponents that need it. When an `Instance` is being brought offline (from server shutdown/restart/update or user request) the same pattern is followed calling `StopAsync()`. +Many classes in here implement [IHostedService](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-8.0&tabs=visual-studio), `InstanceManager` being the only one that is called by the ASP.NET runtime. In the case of instances `StartAsync()` is called when an `Instance` is being brought online (from server startup or user request). The `Instance` handles calling `StartAsync()` on its various subcomponents that need it. When an `Instance` is being brought offline (from server shutdown/restart/update or user request) the same pattern is followed calling `StopAsync()`. diff --git a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs index 33cab94dcf..4402b956b9 100644 --- a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs @@ -34,24 +34,8 @@ namespace Tgstation.Server.Host.Database if (databaseConfiguration.DatabaseType != DatabaseType.SqlServer) throw new InvalidOperationException($"Invalid DatabaseType for {nameof(SqlServerDatabaseContext)}!"); -#if NET7_0_OR_GREATER -#error Perform this breaking config change -#endif - - // Workaround for breaking change https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/breaking-changes#encrypt-true - var connectionString = databaseConfiguration.ConnectionString; - if (!connectionString.Contains("Encrypt=", StringComparison.OrdinalIgnoreCase)) - { - var connectionStringBuilder = new SqlConnectionStringBuilder(databaseConfiguration.ConnectionString) - { - Encrypt = false, - }; - - connectionString = connectionStringBuilder.ToString(); - } - options.UseSqlServer( - connectionString, + databaseConfiguration.ConnectionString, sqlServerOptions => { sqlServerOptions.EnableRetryOnFailure(); diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index 23d36cafd5..ca3ba2cd28 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -284,8 +284,8 @@ namespace Tgstation.Server.Host.IO path = ResolvePath(path); ArgumentNullException.ThrowIfNull(zipFile); -#if NET7_0_OR_GREATER -#warning Check if zip file seeking has been addressesed. See https://github.com/tgstation/tgstation-server/issues/1531 +#if NET9_0_OR_GREATER +#error Check if zip file seeking has been addressesed. See https://github.com/tgstation/tgstation-server/issues/1531 #endif // ZipArchive does a synchronous copy on unseekable streams we want to avoid diff --git a/src/Tgstation.Server.Host/README.md b/src/Tgstation.Server.Host/README.md index ccb01971a6..1f8df0feee 100644 --- a/src/Tgstation.Server.Host/README.md +++ b/src/Tgstation.Server.Host/README.md @@ -12,8 +12,8 @@ Server startup can be a bit complicated so here's a walkthrough 1. `CreateServer()` is called on the `IServerFactory` to get the `IServer` instance. - The factory pattern is used throughout TGS to construct implementations where the composition root is not sufficient. `ServerFactory` is somewhat of an exception to this because it exists outside of the dependency injection umbrella. 1. Inside `CreateServer()` we run the [setup code](./Setup) if need be. - - This is implemented as a separate [dotnet host](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-6.0) to the main server. -1. Still inside `CreateServer()` we configure the main [dotnet host (IHostBuilder)](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-6.0) using the application [Application](./Core/Application.cs) class as the [Startup class](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/startup?view=aspnetcore-6.0#the-startup-class). + - This is implemented as a separate [dotnet host](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-8.0) to the main server. +1. Still inside `CreateServer()` we configure the main [dotnet host (IHostBuilder)](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-8.0) using the application [Application](./Core/Application.cs) class as the [Startup class](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/startup?view=aspnetcore-8.0#the-startup-class). 1. The `IHostBuilder` is used to construct the return `Server` implementation. 1. `Run()` is called on the `IServer` instance. 1. The DI container is built using the [Application](./Core/Application.cs) class. diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs index 0256395b7d..4ef38513a4 100644 --- a/src/Tgstation.Server.Host/ServerFactory.cs +++ b/src/Tgstation.Server.Host/ServerFactory.cs @@ -89,7 +89,7 @@ namespace Tgstation.Server.Host // CURSED // https://github.com/dotnet/runtime/blob/30dc7e7aedb7aab085c7d9702afeae5bc5a43133/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs#L246-L249 -#if !NET6_0 +#if !NET8_0 #error Validate this monstrosity works on current .NET #endif IConfigurationSource cmdLineConfig, baseYmlConfig, environmentYmlConfig; @@ -141,7 +141,7 @@ namespace Tgstation.Server.Host var serverPortProvider = kestrelOptions.ApplicationServices.GetRequiredService(); kestrelOptions.ListenAnyIP( serverPortProvider.HttpApiPort, - listenOptions => listenOptions.Protocols = HttpProtocols.Http1AndHttp2); + listenOptions => listenOptions.Protocols = HttpProtocols.Http1); // Can't use Http1And2 without TLS. Let the reverse proxy handle it // with 515 we lost the ability to test this effectively. Just bump it slightly above the default and let the existing limit hold us back kestrelOptions.Limits.MaxRequestLineSize = 8400; diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index dcf5490971..d11a12e45d 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -512,16 +512,16 @@ namespace Tgstation.Server.Host.Setup } while (true); - bool useWinAuth; + var useWinAuth = false; + var encrypt = false; if (databaseConfiguration.DatabaseType == DatabaseType.SqlServer && platformIdentifier.IsWindows) { var defaultResponse = serverAddressEntry?.AddressList.Any(IPAddress.IsLoopback) ?? false ? (bool?)true : null; useWinAuth = await PromptYesNo("Use Windows Authentication?", defaultResponse, cancellationToken); + encrypt = await PromptYesNo("Use encrypted connection?", false, cancellationToken); } - else - useWinAuth = false; await console.WriteAsync(null, true, cancellationToken); @@ -567,6 +567,7 @@ namespace Tgstation.Server.Host.Setup { ApplicationName = assemblyInformationProvider.VersionPrefix, DataSource = serverAddress ?? "(local)", + Encrypt = encrypt, }; if (useWinAuth) diff --git a/src/Tgstation.Server.Host/System/ProcessExecutor.cs b/src/Tgstation.Server.Host/System/ProcessExecutor.cs index 8c9f98bd65..a4418d7a5f 100644 --- a/src/Tgstation.Server.Host/System/ProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/ProcessExecutor.cs @@ -202,16 +202,13 @@ namespace Tgstation.Server.Host.System bool outputOpen = true, errorOpen = true; async Task GetNextLine() { -#if NET7_0_OR_GREATER -#error ReadLineAsync supports cancellation now -#endif if (outputOpen && outputReadTask == null) - outputReadTask = stdOutHandle.ReadLineAsync(); + outputReadTask = stdOutHandle.ReadLineAsync(disposeToken).AsTask(); if (errorOpen && errorReadTask == null) - errorReadTask = stdErrHandle.ReadLineAsync(); + errorReadTask = stdErrHandle.ReadLineAsync(disposeToken).AsTask(); - var completedTask = await Task.WhenAny(outputReadTask ?? errorReadTask, errorReadTask ?? outputReadTask).WaitAsync(disposeToken); + var completedTask = await Task.WhenAny(outputReadTask ?? errorReadTask, errorReadTask ?? outputReadTask); var line = await completedTask; if (completedTask == outputReadTask) { @@ -243,8 +240,8 @@ namespace Tgstation.Server.Host.System { if (fileStream != null) { - await writer.WriteLineAsync(text); - await writer.FlushAsync(); + await writer.WriteLineAsync(text.AsMemory(), disposeToken); + await writer.FlushAsync(disposeToken); } else stringBuilder.AppendLine(text); @@ -267,7 +264,7 @@ namespace Tgstation.Server.Host.System /// /// The to create a from. /// The based on . - IProcess CreateFromExistingHandle(global::System.Diagnostics.Process handle) + Process CreateFromExistingHandle(global::System.Diagnostics.Process handle) { try { diff --git a/src/Tgstation.Server.Host/System/SystemDManager.cs b/src/Tgstation.Server.Host/System/SystemDManager.cs index aa4efd944e..90ffe101de 100644 --- a/src/Tgstation.Server.Host/System/SystemDManager.cs +++ b/src/Tgstation.Server.Host/System/SystemDManager.cs @@ -53,7 +53,7 @@ namespace Tgstation.Server.Host.System /// /// A representing the clock time in nanoseconds. /// See https://linux.die.net/man/3/clock_gettime. - static long GetMonotonicUsec() => global::System.Diagnostics.Stopwatch.GetTimestamp(); // HACK: https://github.com/dotnet/runtime/blob/v6.0.19/src/libraries/Native/Unix/System.Native/pal_time.c#L51 clock_gettime_nsec_np is an OSX only thing apparently... + static long GetMonotonicUsec() => global::System.Diagnostics.Stopwatch.GetTimestamp(); // HACK: https://github.com/dotnet/runtime/blob/v8.0.0-preview.6.23329.7/src/native/libs/System.Native/pal_time.c#L84 clock_gettime_nsec_np is an OSX only thing apparently... /// /// Initializes a new instance of the class. diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 559566784d..e413cc6fe8 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -71,25 +71,25 @@ - + - + - + - + runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - + @@ -113,13 +113,13 @@ - + - + - + diff --git a/src/Tgstation.Server.Host/Utils/README.md b/src/Tgstation.Server.Host/Utils/README.md index bad6a54616..0eb93a2618 100644 --- a/src/Tgstation.Server.Host/Utils/README.md +++ b/src/Tgstation.Server.Host/Utils/README.md @@ -5,5 +5,5 @@ This is a bag of classes used throughout TGS that don't quite belong anywhere el - [IAsyncDelayer](./IAsyncDelayer.cs) and [implementation](./AsyncDelayer.cs) is a class used to sleep code. It's generally a no-op in test scenarios. - [IGitHubClientFactory](./IGitHubClientFactory.cs) and [implementation](./GitHubClientFactory.cs) is a class used to create GitHub API clients using [ocktokit.net](https://github.com/octokit/octokit.net). - [OpenApiEnumVarNamesExtension](./OpenApiEnumVarNamesExtension) implements the [x-var-names OpenAPI 3.0 extension](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md#enum) in our generated API json. -- [SemaphoreSlimContext](./SemaphoreSlimContext.cs) is a helper class for working with [.NET asynchronous sempahores](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netcore-6.0). +- [SemaphoreSlimContext](./SemaphoreSlimContext.cs) is a helper class for working with [.NET asynchronous sempahores](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netcore-8.0). - [SwaggerConfiguration](./SwaggerConfiguration.cs) configures [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) to generate our OpenAPI specification. diff --git a/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs b/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs index 7ad15d9ad0..c60d7308c2 100644 --- a/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs +++ b/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs @@ -181,6 +181,8 @@ namespace Tgstation.Server.Host.Setup.Tests "no", //test winauth "yes", + // encrypt + "YES", //sql server will always fail so reconfigure with maria nameof(DatabaseType.MariaDB), "127.0.0.1", diff --git a/tests/Tgstation.Server.Host.Tests/Utils/TestAsyncDelayer.cs b/tests/Tgstation.Server.Host.Tests/Utils/TestAsyncDelayer.cs index 2760e9a4fe..fcad8785c5 100644 --- a/tests/Tgstation.Server.Host.Tests/Utils/TestAsyncDelayer.cs +++ b/tests/Tgstation.Server.Host.Tests/Utils/TestAsyncDelayer.cs @@ -13,8 +13,8 @@ namespace Tgstation.Server.Host.Utils.Tests public async Task TestDelay() { var delayer = new AsyncDelayer(); - var startDelay = delayer.Delay(TimeSpan.FromSeconds(1), default); - var checkDelay = Task.Delay(TimeSpan.FromSeconds(1) - TimeSpan.FromMilliseconds(100), default); + var startDelay = delayer.Delay(TimeSpan.FromSeconds(1), CancellationToken.None); + var checkDelay = Task.Delay(TimeSpan.FromSeconds(1) - TimeSpan.FromMilliseconds(100), CancellationToken.None); await startDelay; Assert.IsTrue(checkDelay.IsCompleted); } diff --git a/tools/Tgstation.Server.Migrator/Program.cs b/tools/Tgstation.Server.Migrator/Program.cs index 83afbe2500..69783b68f3 100644 --- a/tools/Tgstation.Server.Migrator/Program.cs +++ b/tools/Tgstation.Server.Migrator/Program.cs @@ -24,9 +24,9 @@ using Tgstation.Server.Client; using Tgstation.Server.Common; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Common.Http; -using Tgstation.Server.Host.Common; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Setup; +using Tgstation.Server.Migrator.Properties; using FileMode = System.IO.FileMode; @@ -226,7 +226,7 @@ try Console.WriteLine("Attempting to create TGS install directory..."); Directory.CreateDirectory(tgsInstallPath); - // ASP.NET 6.0 RUNTIME CHECK + // ASP.NET 8.0 RUNTIME CHECK Console.WriteLine("Next step, we need to ensure the ASP.NET Core 6 runtime is installed on your machine."); Console.WriteLine("We're going to download it for you."); Console.WriteLine("Yes, this program runs .NET 6, but it contains the entire runtime embedded into it. You will need a system-wide install for TGS."); @@ -253,14 +253,14 @@ try if (runtimeInstalled) { var versions = await dotnetRuntimeCheck.StandardOutput.ReadToEndAsync(); - var regex = new Regex("Microsoft\\.AspNetCore\\.App 6\\.0\\.[0-9]+"); + var regex = new Regex("Microsoft\\.AspNetCore\\.App 8\\.0\\.[0-9]+"); if (!regex.IsMatch(versions)) runtimeInstalled = false; } } - // ASP.NET 6.0 RUNTIME SETUP + // ASP.NET 8.0 RUNTIME SETUP var assemblyName = currentAssembly.GetName(); var productInfoHeaderValue = new ProductInfoHeaderValue( @@ -276,9 +276,9 @@ try var xSubstitution = x64 ? "64" : "86"; Console.WriteLine($"Running on an x{xSubstitution} system."); - var downloadUri = new Uri("https://download.visualstudio.microsoft.com/download/pr/eaa3eab9-cc21-44b5-a4e4-af31ee73b9fa/d8ad75d525dec0a30b52adc990796b11/dotnet-hosting-6.0.9-win.exe"); + var downloadUri = RuntimeDistributableAttribute.Instance.RuntimeDistributableUrl; - var dotnetDownloadFilePath = $"dotnet-hosting-6.0.9-win.exe"; + var dotnetDownloadFilePath = $"dotnet-hosting-bundle-installer.exe"; Console.WriteLine($"Downloading {downloadUri} to {Path.GetFullPath(dotnetDownloadFilePath)}..."); @@ -327,7 +327,7 @@ try if (!PromptYesOrNo("Was the installation successful?")) { - Console.WriteLine("Cannot continue without ASP.NET 6.0 runtime installed."); + Console.WriteLine("Cannot continue without ASP.NET 8.0 runtime installed."); ExitPause(2); } } diff --git a/tools/Tgstation.Server.Migrator/Properties/RuntimeDistributableAttribute.cs b/tools/Tgstation.Server.Migrator/Properties/RuntimeDistributableAttribute.cs new file mode 100644 index 0000000000..d4434c61bb --- /dev/null +++ b/tools/Tgstation.Server.Migrator/Properties/RuntimeDistributableAttribute.cs @@ -0,0 +1,34 @@ +using System; +using System.Reflection; + +namespace Tgstation.Server.Migrator.Properties +{ + /// + /// Attribute for bringing in the runtime redistributable download link + /// + [AttributeUsage(AttributeTargets.Assembly)] + sealed class RuntimeDistributableAttribute : Attribute + { + /// + /// Return the 's instance of the . + /// + public static RuntimeDistributableAttribute Instance => Assembly + .GetExecutingAssembly() + .GetCustomAttribute()!; + + /// + /// The of the current runtime distributable. + /// + public Uri RuntimeDistributableUrl { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + public RuntimeDistributableAttribute( + string runtimeDistributableUrl) + { + RuntimeDistributableUrl = new Uri(runtimeDistributableUrl ?? throw new ArgumentNullException(nameof(runtimeDistributableUrl))); + } + } +} diff --git a/tools/Tgstation.Server.Migrator/Tgstation.Server.Migrator.csproj b/tools/Tgstation.Server.Migrator/Tgstation.Server.Migrator.csproj index a74f718d7c..2214e42092 100644 --- a/tools/Tgstation.Server.Migrator/Tgstation.Server.Migrator.csproj +++ b/tools/Tgstation.Server.Migrator/Tgstation.Server.Migrator.csproj @@ -1,9 +1,9 @@ - + Exe - $(TgsFrameworkVersion) + $(TgsFrameworkVersion) win-x86 $(TgsMigratorVersion) enable @@ -15,6 +15,19 @@ + + + + <_Parameter1>$(TgsDotnetRedistUrl) + + + + + + + + +