Remove trimming and self contained to fix plugins, fixes #83

This commit is contained in:
AeonLucid committed 2020-10-25 22:01:28 +01:00
1 parent 6c18531f62
commit 4c3d822fb7
7 files changed
+49 -27

No files matched your search

+1 -1
View 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
+1
View File
@@ -31,6 +31,7 @@ test: off
artifacts:
- path: ./build/*.zip
- path: ./build/*.tar.gz
- path: ./build/*.nupkg
- path: ./build/*.snupkg
+29 -13
View 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 {
+9 -7
View 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
@@ -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>
@@ -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>
@@ -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();