mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 22:17:51 +01:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+2
-2
@@ -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 \
|
||||
|
||||
+4
-4
@@ -3,8 +3,8 @@
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<Import Project="ControlPanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>5.14.0</TgsCoreVersion>
|
||||
<TgsConfigVersion>4.7.1</TgsConfigVersion>
|
||||
<TgsCoreVersion>6.0.0</TgsCoreVersion>
|
||||
<TgsConfigVersion>5.0.0</TgsConfigVersion>
|
||||
<TgsApiVersion>9.11.0</TgsApiVersion>
|
||||
<TgsCommonLibraryVersion>6.0.0</TgsCommonLibraryVersion>
|
||||
<TgsApiLibraryVersion>11.0.0</TgsApiLibraryVersion>
|
||||
@@ -15,9 +15,9 @@
|
||||
<TgsContainerScriptVersion>1.2.1</TgsContainerScriptVersion>
|
||||
<TgsMigratorVersion>1.0.2</TgsMigratorVersion>
|
||||
<TgsNugetNetFramework>netstandard2.0</TgsNugetNetFramework>
|
||||
<TgsNetMajorVersion>6</TgsNetMajorVersion>
|
||||
<TgsNetMajorVersion>8</TgsNetMajorVersion>
|
||||
<!-- Update this frequently with dotnet runtime patches. MAJOR MUST MATCH ABOVE! -->
|
||||
<TgsDotnetRedistUrl>https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/6.0.20/dotnet-hosting-6.0.20-win.exe</TgsDotnetRedistUrl>
|
||||
<TgsDotnetRedistUrl>https://download.visualstudio.microsoft.com/download/pr/e5db48f5-99c6-42ca-804a-85b89ae09671/b5594181b347a9a77246e3645916bd0e/dotnet-hosting-8.0.0-preview.6.23329.11-win.exe</TgsDotnetRedistUrl>
|
||||
<TgsMariaDBRedistVersion>11.0.2</TgsMariaDBRedistVersion>
|
||||
<!-- The two versions must match above, this is referenced by scripts so we can't use an MSBuild property reference -->
|
||||
<TgsMariaDBRedistUrl>https://ftp.osuosl.org/pub/mariadb/mariadb-11.0.2/winx64-packages/mariadb-11.0.2-winx64.msi</TgsMariaDBRedistUrl>
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Maintainer: Jordan Dominion <Cyberboss@users.noreply.github.com>
|
||||
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],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,20 +9,9 @@
|
||||
<ApplicationManifest>../../build/uac_elevation_manifest.xml</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<DocumentationFile>bin\Release\net6.0\Tgstation.Server.Host.Console.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;SA1652</NoWarn>
|
||||
<DocumentationFile>bin\Debug\net6.0\Tgstation.Server.Host.Console.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Usage: Console logging plugin -->
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-preview.6.23329.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
<!-- Usage: Command line argument support -->
|
||||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
|
||||
<!-- Usage: Identifies when we are running in the context of the Windows SCM -->
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0-preview.6.23329.7" />
|
||||
<!-- Usage: Windows event log logging plugin -->
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0-preview.6.23329.7" />
|
||||
<!-- Usage: Console logging plugin -->
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-preview.6.23329.7" />
|
||||
<!-- Usage: OS identification -->
|
||||
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
|
||||
<!-- Usage: Windows Service Manager intergration -->
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.1" />
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0-preview.6.23329.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Usage: Logging abstractions -->
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-preview.6.23329.7" />
|
||||
<!-- Usage: POSIX support for signals -->
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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()`.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<IServerPortProvider>();
|
||||
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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -202,16 +202,13 @@ namespace Tgstation.Server.Host.System
|
||||
bool outputOpen = true, errorOpen = true;
|
||||
async Task<string> 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
|
||||
/// </summary>
|
||||
/// <param name="handle">The <see cref="global::System.Diagnostics.Process"/> to create a <see cref="IProcess"/> from.</param>
|
||||
/// <returns>The <see cref="IProcess"/> based on <paramref name="handle"/>.</returns>
|
||||
IProcess CreateFromExistingHandle(global::System.Diagnostics.Process handle)
|
||||
Process CreateFromExistingHandle(global::System.Diagnostics.Process handle)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Tgstation.Server.Host.System
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="long"/> representing the clock time in nanoseconds.</returns>
|
||||
/// <remarks>See https://linux.die.net/man/3/clock_gettime.</remarks>
|
||||
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...
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SystemDManager"/> class.
|
||||
|
||||
@@ -71,25 +71,25 @@
|
||||
<!-- Usage: git interop -->
|
||||
<PackageReference Include="LibGit2Sharp" Version="0.27.2" />
|
||||
<!-- Usage: JWT injection into HTTP pipeline -->
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.20" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0-preview.6.23329.11" />
|
||||
<!-- Usage: Support ""legacy"" Newotonsoft.Json in HTTP pipeline. The rest of our codebase uses Newtonsoft. -->
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.20" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0-preview.6.23329.11" />
|
||||
<!-- Usage: Database ORM -->
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-preview.6.23329.4" />
|
||||
<!-- Usage: Automatic migration generation using command line -->
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0-preview.6.23329.4">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<!-- Usage: Sqlite ORM plugin -->
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-preview.6.23329.4" />
|
||||
<!-- Usage: MSSQL ORM plugin -->
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-preview.6.23329.4" />
|
||||
<!-- Usage: POSIX support for syscalls, signals, and symlinks -->
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
<!-- Usage: YAML config plugin -->
|
||||
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
|
||||
<!-- Usage: PostgresSQL ORM plugin -->
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.4" />
|
||||
<!-- Usage: GitHub.com interop -->
|
||||
<PackageReference Include="Octokit" Version="7.0.1" />
|
||||
<!-- Usage: MYSQL/MariaDB ORM plugin -->
|
||||
@@ -113,13 +113,13 @@
|
||||
<!-- Usage: Access to raw database connectors primarily for setup wizard -->
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||
<!-- Usage: Windows authentication plugin allowing searching for users by name -->
|
||||
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="7.0.0" />
|
||||
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="8.0.0-preview.6.23329.7" />
|
||||
<!-- Usage: JWT plugin needed to undo some Microsoft meddling in the HTTP pipeline -->
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.0" />
|
||||
<!-- Usage: Identifying owning user of Windows Process objects -->
|
||||
<PackageReference Include="System.Management" Version="7.0.2" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0-preview.6.23329.7" />
|
||||
<!-- Usage: .DeleteAsync() support for IQueryable<T>s -->
|
||||
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="7.22.4" />
|
||||
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="8.0.0-preview.5.23280.1-02" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Tgstation.Server.Migrator.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for bringing in the runtime redistributable download link
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
sealed class RuntimeDistributableAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the <see cref="Assembly"/>'s instance of the <see cref="MasterVersionsAttribute"/>.
|
||||
/// </summary>
|
||||
public static RuntimeDistributableAttribute Instance => Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetCustomAttribute<RuntimeDistributableAttribute>()!;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Uri"/> of the current runtime distributable.
|
||||
/// </summary>
|
||||
public Uri RuntimeDistributableUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MasterVersionsAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="runtimeDistributableUrl">The <see cref="string"/> value of <see cref="RuntimeDistributableUrl"/>.</param>
|
||||
public RuntimeDistributableAttribute(
|
||||
string runtimeDistributableUrl)
|
||||
{
|
||||
RuntimeDistributableUrl = new Uri(runtimeDistributableUrl ?? throw new ArgumentNullException(nameof(runtimeDistributableUrl)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="../../build/Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>$(TgsFrameworkVersion)</TargetFramework>
|
||||
<TargetFramework>$(TgsFrameworkVersion)</TargetFramework> <!-- This is fine, we publish self-contained -->
|
||||
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
|
||||
<Version>$(TgsMigratorVersion)</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -15,6 +15,19 @@
|
||||
<PackageReference Include="Core.System.ServiceProcess" Version="2.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="ApplyRuntimeDistributableAttribute" BeforeTargets="CoreCompile">
|
||||
<ItemGroup>
|
||||
<AssemblyAttributes Include="Tgstation.Server.Migrator.Properties.RuntimeDistributableAttribute">
|
||||
<_Parameter1>$(TgsDotnetRedistUrl)</_Parameter1>
|
||||
</AssemblyAttributes>
|
||||
</ItemGroup>
|
||||
|
||||
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttributes)" Language="C#" OutputDirectory="$(IntermediateOutputPath)" OutputFile="RuntimeDistributableAssemblyInfo.cs">
|
||||
<Output TaskParameter="OutputFile" ItemName="Compile" />
|
||||
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
|
||||
</WriteCodeFragment>
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Tgstation.Server.Client\Tgstation.Server.Client.csproj" />
|
||||
<ProjectReference Include="..\..\src\Tgstation.Server.Host\Tgstation.Server.Host.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user