]> git.deb.at Git - rhonda/impostor.git/commitdiff
Remove trimming and self contained to fix plugins, fixes #83
authorAeonLucid <aeonlucid@outlook.com>
Sun, 25 Oct 2020 21:01:28 +0000 (22:01 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Sun, 25 Oct 2020 21:01:28 +0000 (22:01 +0100)
Dockerfile
appveyor.yml
build.cake
docs/Running-the-server.md
src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj
src/Impostor.Server/Impostor.Server.csproj
src/Impostor.Server/Plugins/PluginLoaderService.cs

index 3066607985489c053e96a97b553a07577308aa18..8f386da6021ef765564425031d24bc706584ba42 100644 (file)
@@ -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
index 9eb191090d6ecc615095146ef120bf142d4acb58..d1b4f657ba40298f57d174b63a6ed50bd80b622a 100644 (file)
@@ -31,6 +31,7 @@ test: off
 
 artifacts:
   - path: ./build/*.zip
+  - path: ./build/*.tar.gz
   - path: ./build/*.nupkg
   - path: ./build/*.snupkg
 
index 0be7233cbaa616d9561f6992b8a22b7b3432496b..14491d6100854a2343ce8e110f5644aed6f56423 100644 (file)
@@ -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 {
index 3924f6c09ebae0d561142179fe6896b649a96593..d948a4875f7bcb362fadb453502e8a92abc2f45a 100644 (file)
@@ -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
index 4004bd6f32b0611f61b72f434e62f2cb96e069f1..74f32d7a17ad16e1eeae0387cd445c3e868acb48 100644 (file)
@@ -5,8 +5,6 @@
         <TargetFramework>net5.0</TargetFramework>
         <RuntimeIdentifiers>win-x64;linux-x64;linux-arm;linux-arm64;osx-x64</RuntimeIdentifiers>
         <OutputType>Exe</OutputType>
-        <PublishTrimmed>true</PublishTrimmed>
-        <TrimMode>Link</TrimMode>
         <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
     </PropertyGroup>
 
index a1fdf6f812c46db45eda7fd18b666cd25c0af35e..7f95640c7a5e7d762c7e99e8e6343102c884cd29 100644 (file)
@@ -4,8 +4,6 @@
         <OutputType>Exe</OutputType>
         <TargetFramework>net5.0</TargetFramework>
         <RuntimeIdentifiers>win-x64;linux-x64;linux-arm;linux-arm64;osx-x64</RuntimeIdentifiers>
-        <PublishTrimmed>true</PublishTrimmed>
-        <TrimMode>Link</TrimMode>
         <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
         <ApplicationIcon>icon.ico</ApplicationIcon>
         <CodeAnalysisRuleSet>ProjectRules.ruleset</CodeAnalysisRuleSet>
index 7ba4b77ac5ec08686bbcbdb9ea57f65816a84163..0afbc223918f67957e5e15566ca7e7bf1b29e168 100644 (file)
@@ -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();