From 4c3d822fb744b66c168f379c0840ebdb2d240723 Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Sun, 25 Oct 2020 22:01:28 +0100 Subject: [PATCH] Remove trimming and self contained to fix plugins, fixes #83 --- Dockerfile | 2 +- appveyor.yml | 1 + build.cake | 42 +++++++++++++------ docs/Running-the-server.md | 16 +++---- .../Impostor.Patcher.Cli.csproj | 2 - src/Impostor.Server/Impostor.Server.csproj | 2 - .../Plugins/PluginLoaderService.cs | 11 ++++- 7 files changed, 49 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3066607..8f386da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ RUN case "$TARGETARCH" in \ dotnet publish -c release -o /app -r "$NETCORE_PLATFORM" --no-restore ./src/Impostor.Server/Impostor.Server.csproj # Final image. -FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:5.0 +FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime:5.0 WORKDIR /app COPY --from=build /app ./ EXPOSE 22023/udp diff --git a/appveyor.yml b/appveyor.yml index 9eb1910..d1b4f65 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,6 +31,7 @@ test: off artifacts: - path: ./build/*.zip + - path: ./build/*.tar.gz - path: ./build/*.nupkg - path: ./build/*.snupkg diff --git a/build.cake b/build.cake index 0be7233..14491d6 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,8 @@ +#addin "nuget:?package=SharpZipLib&Version=1.3.0" +#addin "nuget:?package=Cake.Compression&Version=0.2.4" #addin "nuget:?package=Cake.FileHelpers&Version=3.3.0" + var buildId = EnvironmentVariable("APPVEYOR_BUILD_VERSION") ?? "0"; var buildVersion = EnvironmentVariable("IMPOSTOR_VERSION") ?? "1.0.0"; var buildBranch = EnvironmentVariable("APPVEYOR_REPO_BRANCH") ?? "dev"; @@ -25,24 +28,37 @@ private void ImpostorClean(string directory) { } } -private void ImpostorPublish(string name, string project, string runtime, bool selfContained = true) { +private void ImpostorPublish(string name, string project, string runtime, bool isServer = false) { var projBuildDir = buildDir.Combine(name + "_" + runtime); - var projBuildZip = buildDir.CombineWithFilePath(name + "_" + buildVersion + "_" + runtime + ".zip"); + var projBuildName = name + "_" + buildVersion + "_" + runtime; DotNetCorePublish(project, new DotNetCorePublishSettings { Configuration = configuration, NoRestore = true, Framework = "net5.0", Runtime = runtime, - SelfContained = selfContained, + SelfContained = false, PublishSingleFile = true, - PublishTrimmed = selfContained, + PublishTrimmed = false, OutputDirectory = projBuildDir }); ImpostorClean(projBuildDir.ToString()); - Zip(projBuildDir, projBuildZip); + if (isServer) { + CreateDirectory(projBuildDir.Combine("plugins")); + CreateDirectory(projBuildDir.Combine("libraries")); + + if (runtime == "win-x64") { + FileWriteText(projBuildDir.CombineWithFilePath("run.bat"), "@echo off\r\nImpostor.Server.exe\r\npause"); + } + } + + if (runtime == "win-x64") { + Zip(projBuildDir, buildDir.CombineWithFilePath(projBuildName + ".zip")); + } else { + GZipCompress(projBuildDir, buildDir.CombineWithFilePath(projBuildName + ".tar.gz")); + } } private void ImpostorPublishNF(string name, string project) { @@ -104,16 +120,16 @@ Task("Build") // Client. ImpostorPublishNF("Impostor-Patcher", "./src/Impostor.Patcher/Impostor.Patcher.WinForms/Impostor.Patcher.WinForms.csproj"); - ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "win-x64", false); - ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "osx-x64", false); - ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "linux-x64", false); + ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "win-x64"); + ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "osx-x64"); + ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "linux-x64"); // Server. - ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "win-x64"); - ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "osx-x64"); - ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-x64"); - ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm"); - ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm64"); + ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "win-x64", true); + ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "osx-x64", true); + ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-x64", true); + ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm", true); + ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm64", true); // API. DotNetCorePack("./src/Impostor.Api/Impostor.Api.csproj", new DotNetCorePackSettings { diff --git a/docs/Running-the-server.md b/docs/Running-the-server.md index 3924f6c..d948a48 100644 --- a/docs/Running-the-server.md +++ b/docs/Running-the-server.md @@ -5,11 +5,15 @@ There are currently two modes to run the Impostor server in. The first way is th ## Single server ### Without docker -1. Find the [latest release](https://github.com/AeonLucid/Impostor/releases/latest). -2. Download either the Windows or the Linux version. -3. Extract the zip. -4. Modify `config.json` to your liking. -5. Run `Impostor.Server.exe` (Windows) / `Impostor.Server` (Linux) +1. Install the **.NET 5.0 runtime**. + - [Windows x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-aspnetcore-5.0.0-rc.2-windows-x64-binaries) + - [Linux x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-aspnetcore-5.0.0-rc.2-linux-x64-binaries) + - [macOS x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-aspnetcore-5.0.0-rc.2-macos-x64-binaries) +2. Find the [latest release](https://github.com/AeonLucid/Impostor/releases/latest). +3. Download either the Windows or the Linux version. +4. Extract the zip. +5. Modify `config.json` to your liking. +6. Run `Impostor.Server.exe` (Windows) / `Impostor.Server` (Linux) ### Using docker @@ -22,8 +26,6 @@ docker run -p 22023:22023/udp aeonlucid/impostor ## Multiple servers -**This is only in the `dev` branch at this moment so you will need to build it yourself.** - Follow the steps from the single server on two or more servers. ### Master server diff --git a/src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj b/src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj index 4004bd6..74f32d7 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj +++ b/src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj @@ -5,8 +5,6 @@ net5.0 win-x64;linux-x64;linux-arm;linux-arm64;osx-x64 Exe - true - Link true diff --git a/src/Impostor.Server/Impostor.Server.csproj b/src/Impostor.Server/Impostor.Server.csproj index a1fdf6f..7f95640 100644 --- a/src/Impostor.Server/Impostor.Server.csproj +++ b/src/Impostor.Server/Impostor.Server.csproj @@ -4,8 +4,6 @@ Exe net5.0 win-x64;linux-x64;linux-arm;linux-arm64;osx-x64 - true - Link true icon.ico ProjectRules.ruleset diff --git a/src/Impostor.Server/Plugins/PluginLoaderService.cs b/src/Impostor.Server/Plugins/PluginLoaderService.cs index 7ba4b77..0afbc22 100644 --- a/src/Impostor.Server/Plugins/PluginLoaderService.cs +++ b/src/Impostor.Server/Plugins/PluginLoaderService.cs @@ -25,9 +25,11 @@ namespace Impostor.Server.Plugins public async Task StartAsync(CancellationToken cancellationToken) { + _logger.LogInformation("Loading plugins."); + foreach (var plugin in _plugins) { - _logger.LogInformation("Enabling plugin {0}", plugin); + _logger.LogInformation("Enabling plugin {0}.", plugin); // Create instance and inject services. plugin.Instance = (IPlugin) ActivatorUtilities.CreateInstance(_serviceProvider, plugin.PluginType); @@ -35,6 +37,11 @@ namespace Impostor.Server.Plugins // Enable plugin. await plugin.Instance.EnableAsync(); } + + _logger.LogInformation( + _plugins.Count == 1 + ? "Loaded {0} plugin." + : "Loaded {0} plugins.", _plugins.Count); } public async Task StopAsync(CancellationToken cancellationToken) @@ -43,7 +50,7 @@ namespace Impostor.Server.Plugins // In the case of a failed startup, some can be null. foreach (var plugin in _plugins.Where(plugin => plugin.Instance != null)) { - _logger.LogInformation("Disabling plugin {0}", plugin); + _logger.LogInformation("Disabling plugin {0}.", plugin); // Disable plugin. await plugin.Instance.DisableAsync(); -- 2.39.5