From 380ba46f11dd9fe862e1fcf81463ea4f323355a2 Mon Sep 17 00:00:00 2001 From: miniduikboot Date: Wed, 25 May 2022 19:52:22 +0200 Subject: [PATCH] Upgrade to .NET 6 (#479) * Upgrade to .NET 6 .NET 5 has gone EOL, so move to a supported version. * Upgrade Docker container as well * Update docs for .NET 6 * Re-add hack for System.IO.Pipelines * Bump dependency versions * Update the deps of the other projects too * Only declare TargetFramework once * Dockerfile: also copy over Directory.Build.props * Cake: pick up target framework automatically * Upgrade Cake as well --- .config/dotnet-tools.json | 2 +- Dockerfile | 7 +++-- build.cake | 28 +++++++++---------- docs/Building-from-source.md | 4 +-- docs/Running-the-server.md | 4 +-- docs/Writing-a-plugin.md | 11 ++++---- src/Directory.Build.props | 1 + src/Impostor.Api/Impostor.Api.csproj | 4 +-- .../Impostor.Benchmarks.csproj | 3 +- .../Impostor.Client.App.csproj | 3 +- src/Impostor.Client/Impostor.Client.csproj | 4 --- .../Impostor.Plugins.Debugger.csproj | 1 - src/Impostor.Server/Impostor.Server.csproj | 19 ++++++------- src/Impostor.Tests/Impostor.Tests.csproj | 10 ++++--- .../Impostor.Tools.Proxy.csproj | 3 +- .../Impostor.Tools.ServerReplay.csproj | 3 +- 16 files changed, 50 insertions(+), 57 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 6cf141e..7bd5f9f 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "1.1.0", + "version": "2.2.0", "commands": [ "dotnet-cake" ] diff --git a/Dockerfile b/Dockerfile index ae6b070..d13c4f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:5.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build # See for all possible platforms # https://github.com/containerd/containerd/blob/master/platforms/platforms.go#L17 @@ -12,6 +12,7 @@ WORKDIR /source COPY src/Impostor.Server/Impostor.Server.csproj ./src/Impostor.Server/Impostor.Server.csproj COPY src/Impostor.Api/Impostor.Api.csproj ./src/Impostor.Api/Impostor.Api.csproj COPY src/Impostor.Hazel/Hazel/Hazel.csproj ./src/Impostor.Hazel/Hazel/Hazel.csproj +COPY src/Directory.Build.props ./src/Directory.Build.props RUN case "$TARGETARCH" in \ amd64) NETCORE_PLATFORM='linux-x64';; \ @@ -35,8 +36,8 @@ RUN case "$TARGETARCH" in \ dotnet publish -c release -o /app -r "$NETCORE_PLATFORM" -p:VersionSuffix="$VERSIONSUFFIX" --no-restore ./src/Impostor.Server/Impostor.Server.csproj # Final image. -FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime:5.0 +FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime:6.0 WORKDIR /app COPY --from=build /app ./ EXPOSE 22023/udp -ENTRYPOINT ["./Impostor.Server"] \ No newline at end of file +ENTRYPOINT ["./Impostor.Server"] diff --git a/build.cake b/build.cake index d99da2b..67c06ab 100644 --- a/build.cake +++ b/build.cake @@ -1,6 +1,6 @@ -#addin "nuget:?package=SharpZipLib&Version=1.3.1" -#addin "nuget:?package=Cake.Compression&Version=0.2.6" -#addin "nuget:?package=Cake.FileHelpers&Version=4.0.1" +#addin "nuget:?package=SharpZipLib&Version=1.3.3" +#addin "nuget:?package=Cake.Compression&Version=0.3.0" +#addin "nuget:?package=Cake.FileHelpers&Version=5.0.0" var buildId = EnvironmentVariable("GITHUB_RUN_NUMBER") ?? EnvironmentVariable("APPVEYOR_BUILD_VERSION"); var buildRelease = EnvironmentVariable("APPVEYOR_REPO_TAG") == "true"; @@ -10,7 +10,7 @@ var buildDir = MakeAbsolute(Directory("./build")); var target = Argument("target", "Deploy"); var configuration = Argument("configuration", "Release"); -var msbuildSettings = new DotNetCoreMSBuildSettings(); +var msbuildSettings = new DotNetMSBuildSettings(); if (buildRelease) { @@ -31,10 +31,9 @@ private void ImpostorPublish(string name, string project, string runtime, bool i var projBuildDir = buildDir.Combine(name + "_" + runtime); var projBuildName = name + "_" + buildVersion + "_" + runtime; - DotNetCorePublish(project, new DotNetCorePublishSettings { + DotNetPublish(project, new DotNetPublishSettings { Configuration = configuration, NoRestore = true, - Framework = "net5.0", Runtime = runtime, SelfContained = false, PublishSingleFile = true, @@ -64,7 +63,7 @@ private void ImpostorPublishNF(string name, string project) { var projBuildDir = buildDir.Combine(name + "_" + runtime); var projBuildZip = buildDir.CombineWithFilePath(name + "_" + buildVersion + "_" + runtime + ".zip"); - DotNetCorePublish(project, new DotNetCorePublishSettings { + DotNetPublish(project, new DotNetPublishSettings { Configuration = configuration, NoRestore = true, Framework = "net472", @@ -90,18 +89,17 @@ Task("Clean") Task("Restore") .Does(() => { - DotNetCoreRestore("./src/Impostor.sln"); + DotNetRestore("./src/Impostor.sln"); }); Task("Replay") .Does(() => { // D:\Projects\GitHub\Impostor\Impostor\src\Impostor.Tools.ServerReplay\sessions - DotNetCoreRun( + DotNetRun( "./src/Impostor.Tools.ServerReplay/Impostor.Tools.ServerReplay.csproj", - "./src/Impostor.Tools.ServerReplay/sessions", new DotNetCoreRunSettings { + "./src/Impostor.Tools.ServerReplay/sessions", new DotNetRunSettings { Configuration = configuration, NoRestore = true, - Framework = "net5.0" }); }); @@ -111,7 +109,7 @@ Task("Build") .IsDependentOn("Replay") .Does(() => { // Tests. - DotNetCoreBuild("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetCoreBuildSettings { + DotNetBuild("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetBuildSettings { Configuration = configuration, }); @@ -123,7 +121,7 @@ Task("Build") ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm64", true); // API. - DotNetCorePack("./src/Impostor.Api/Impostor.Api.csproj", new DotNetCorePackSettings { + DotNetPack("./src/Impostor.Api/Impostor.Api.csproj", new DotNetPackSettings { Configuration = configuration, OutputDirectory = buildDir, IncludeSource = true, @@ -135,7 +133,7 @@ Task("Build") Task("Test") .IsDependentOn("Build") .Does(() => { - DotNetCoreTest("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetCoreTestSettings { + DotNetTest("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetTestSettings { Configuration = configuration, NoBuild = true }); @@ -151,4 +149,4 @@ Task("Deploy") // EXECUTION ////////////////////////////////////////////////////////////////////// -RunTarget(target); \ No newline at end of file +RunTarget(target); diff --git a/docs/Building-from-source.md b/docs/Building-from-source.md index 1081c76..708bd3f 100644 --- a/docs/Building-from-source.md +++ b/docs/Building-from-source.md @@ -1,6 +1,6 @@ # Building from source -The solution contains the Impostor server and its dependencies, like Hazel and the plugin API. The server is built using [.NET 5](https://dotnet.microsoft.com/download/dotnet/5.0). +The solution contains the Impostor server and its dependencies, like Hazel and the plugin API. The server is built using [.NET 6](https://dotnet.microsoft.com/download/dotnet/6.0). ## Cloning Impostor @@ -14,7 +14,7 @@ git clone https://github.com/Impostor/Impostor.git ### Dependencies -- [.NET 5 SDK](https://dotnet.microsoft.com/download/dotnet/5.0) +- [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) - [Rider](https://www.jetbrains.com/rider/) or [Visual Studio](https://visualstudio.microsoft.com/vs/) (Optional, only if you want the full IDE experience) ### Build using the CLI diff --git a/docs/Running-the-server.md b/docs/Running-the-server.md index 7912f4f..4ab0551 100644 --- a/docs/Running-the-server.md +++ b/docs/Running-the-server.md @@ -6,11 +6,11 @@ There are currently two modes to run the Impostor server. The first way, Single ### Without Docker -1. Install the [.NET 5.0 runtime](https://dotnet.microsoft.com/download). Installing the SDK also works, but is not necessary unless you plan on developing Impostor or Impostor plugins. If you're asked to pick between a console, desktop or server runtime, the console runtime is enough. +1. Install the [.NET 6.0 runtime](https://dotnet.microsoft.com/download/6.0). Installing the SDK also works, but is not necessary unless you plan on developing Impostor or Impostor plugins. If you're asked to pick between a console, desktop or server runtime, the console runtime is enough. 2. Find the [latest release](https://github.com/Impostor/Impostor/releases) or the [latest CI build](https://ci.appveyor.com/project/Impostor/Impostor/branch/master/artifacts). 3. Download the version for your OS (linux/win/osx). Impostor is built for multiple CPU-architectures, you most likely want the x64 version, unless you are running on a Raspberry Pi or another device with an ARM processor. 4. Extract the zip. -5. Modify `config.json` to your liking. Documentation can be found [here](Server-configuration.md) *(this step is mandatory if you want to expose this server to other devices)* +5. Modify `config.json` to your liking. Documentation can be found [here](Server-configuration.md) _(this step is mandatory if you want to expose this server to other devices)_ 6. Run `Impostor.Server` (Linux/macOS) or `Impostor.Server.exe` (Windows) ### Using Docker diff --git a/docs/Writing-a-plugin.md b/docs/Writing-a-plugin.md index b487da1..d40056e 100644 --- a/docs/Writing-a-plugin.md +++ b/docs/Writing-a-plugin.md @@ -19,23 +19,24 @@ Impostor has support for plugins. This document will help you to setup a develop - [Impostor versions](#impostor-versions) - [9. Missing/invalid data or want more functions?](#9-missinginvalid-data-or-want-more-functions) -## 1. Install .NET Core SDK +## 1. Install .NET SDK -Download and install the latest .NET Core SDK. +Download and install the latest .NET SDK. https://dotnet.microsoft.com/download ## 2. Create a C# project -The first step is creating a new C# project, it must be a **Class Library (.NET Standard)**. The target framework can be any of those compatible with .NET 5, which includes: +The first step is creating a new C# project, it must be a **Class Library (.NET Standard)**. The target framework can be any of those compatible with .NET 6, which includes: - .NET Standard 2.0 - .NET Standard 2.1 - .NET 5 +- .NET 6 For more information about compatibility, see https://docs.microsoft.com/en-us/dotnet/standard/net-standard. -> At the moment of writing this document, I recommend you to use **.NET Standard 2.1**. This should give you enough functionality. If not, upgrade to .NET 5. +> At the moment of writing this document, I recommend you to use **.NET Standard 2.1**. This should give you enough functionality. If not, upgrade to .NET 6. When the project has been created, you should have `Class.cs` and `Project.csproj` files. Your `Project.csproj` should look something like this. @@ -336,4 +337,4 @@ Create an issue: - [Suggest a function](https://github.com/Impostor/Impostor/issues/new?template=3--api-suggestion.md) - [Data is invalid](https://github.com/Impostor/Impostor/issues/new?template=4--api-invalid.md) - [Data is unavailable](https://github.com/Impostor/Impostor/issues/new?template=5--api-missing.md) -- [Other](https://github.com/Impostor/Impostor/issues/new?template=6--api-other.md) \ No newline at end of file +- [Other](https://github.com/Impostor/Impostor/issues/new?template=6--api-other.md) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 92f15b3..8811525 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,5 +1,6 @@ + net6.0 1.7.0 dev true diff --git a/src/Impostor.Api/Impostor.Api.csproj b/src/Impostor.Api/Impostor.Api.csproj index 4cd5e42..a21ba48 100644 --- a/src/Impostor.Api/Impostor.Api.csproj +++ b/src/Impostor.Api/Impostor.Api.csproj @@ -27,8 +27,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Impostor.Benchmarks/Impostor.Benchmarks.csproj b/src/Impostor.Benchmarks/Impostor.Benchmarks.csproj index 6f19bda..e747e83 100644 --- a/src/Impostor.Benchmarks/Impostor.Benchmarks.csproj +++ b/src/Impostor.Benchmarks/Impostor.Benchmarks.csproj @@ -2,12 +2,11 @@ Exe - net5.0 true - + diff --git a/src/Impostor.Client.App/Impostor.Client.App.csproj b/src/Impostor.Client.App/Impostor.Client.App.csproj index 3e5adc8..fa708b1 100644 --- a/src/Impostor.Client.App/Impostor.Client.App.csproj +++ b/src/Impostor.Client.App/Impostor.Client.App.csproj @@ -2,7 +2,6 @@ Exe - net5.0 @@ -10,7 +9,7 @@ - + diff --git a/src/Impostor.Client/Impostor.Client.csproj b/src/Impostor.Client/Impostor.Client.csproj index 75e19aa..dee29e0 100644 --- a/src/Impostor.Client/Impostor.Client.csproj +++ b/src/Impostor.Client/Impostor.Client.csproj @@ -1,9 +1,5 @@ - - net5.0 - - diff --git a/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj b/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj index 2aa7625..547835f 100644 --- a/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj +++ b/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj @@ -1,7 +1,6 @@  - net5.0 Library 1.0.0 diff --git a/src/Impostor.Server/Impostor.Server.csproj b/src/Impostor.Server/Impostor.Server.csproj index 49bb222..03ceb76 100644 --- a/src/Impostor.Server/Impostor.Server.csproj +++ b/src/Impostor.Server/Impostor.Server.csproj @@ -2,7 +2,6 @@ Exe - net5.0 win-x64;linux-x64;linux-arm;linux-arm64;osx-x64 true icon.ico @@ -25,18 +24,18 @@ - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/Impostor.Tests/Impostor.Tests.csproj b/src/Impostor.Tests/Impostor.Tests.csproj index a4ccd6b..faa60d7 100644 --- a/src/Impostor.Tests/Impostor.Tests.csproj +++ b/src/Impostor.Tests/Impostor.Tests.csproj @@ -1,16 +1,18 @@ - net5.0 false - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Impostor.Tools.Proxy/Impostor.Tools.Proxy.csproj b/src/Impostor.Tools.Proxy/Impostor.Tools.Proxy.csproj index 1136017..4e07db1 100644 --- a/src/Impostor.Tools.Proxy/Impostor.Tools.Proxy.csproj +++ b/src/Impostor.Tools.Proxy/Impostor.Tools.Proxy.csproj @@ -2,11 +2,10 @@ Exe - net5.0 - + NU1701 diff --git a/src/Impostor.Tools.ServerReplay/Impostor.Tools.ServerReplay.csproj b/src/Impostor.Tools.ServerReplay/Impostor.Tools.ServerReplay.csproj index 3b46f3f..becb742 100644 --- a/src/Impostor.Tools.ServerReplay/Impostor.Tools.ServerReplay.csproj +++ b/src/Impostor.Tools.ServerReplay/Impostor.Tools.ServerReplay.csproj @@ -2,7 +2,6 @@ Exe - net5.0 @@ -10,7 +9,7 @@ - + -- 2.39.5