diff --git a/appveyor.yml b/appveyor.yml
index dc70224a83..b72de09803 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -60,6 +60,8 @@ after_test:
- dotnet publish src/Tgstation.Server.Host/Tgstation.Server.Host.csproj -o ../../artifacts/ServerHost -c %CONFIGURATION%
- dotnet publish src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj -o ../../artifacts/ServerConsole -c %CONFIGURATION%
- ps: Copy-Item -path "src/Tgstation.Server.Host.Service/bin/$env:CONFIGURATION" -destination artifacts/ServerService -recurse
+ - ps: Copy-Item -path "artifacts/ServerHost" -destination artifacts/ServerService/lib/Default -recurse
+ - ps: Copy-Item -path "artifacts/ServerHost" -destination artifacts/ServerConsole/lib/Default -recurse
- ps: $env:TGSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:APPVEYOR_BUILD_FOLDER/artifacts/ServerHost/Tgstation.Server.Host.dll").FileVersion
deploy:
- provider: GitHub
diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
index 96b02fd263..c8c0b05bed 100644
--- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
+++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
@@ -34,7 +34,7 @@
-
+
diff --git a/src/Tgstation.Server.Host.Console.Debug/Program.cs b/src/Tgstation.Server.Host.Console.Debug/Program.cs
new file mode 100644
index 0000000000..231ff0654a
--- /dev/null
+++ b/src/Tgstation.Server.Host.Console.Debug/Program.cs
@@ -0,0 +1,16 @@
+using System.Threading.Tasks;
+using Tgstation.Server.Host.Startup;
+
+namespace Tgstation.Server.Host.Console.Debug
+{
+ static class Program
+ {
+ internal static IServerFactory serverFactory = new ServerFactory();
+
+ static async Task Main(string[] args)
+ {
+ using (var server = serverFactory.CreateServer(args, "Updates"))
+ await server.RunAsync(default).ConfigureAwait(false);
+ }
+ }
+}
diff --git a/src/Tgstation.Server.Host.Console.Debug/Tgstation.Server.Host.Console.Debug.csproj b/src/Tgstation.Server.Host.Console.Debug/Tgstation.Server.Host.Console.Debug.csproj
new file mode 100644
index 0000000000..6369c0169a
--- /dev/null
+++ b/src/Tgstation.Server.Host.Console.Debug/Tgstation.Server.Host.Console.Debug.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ netcoreapp2.0
+
+
+
+ 7.1
+
+
+
+ 7.1
+
+
+
+
+
+
+
diff --git a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj
index c88d318c9c..cb7add9153 100644
--- a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj
+++ b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj
@@ -17,6 +17,10 @@
latest
+
+
+
+
diff --git a/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj b/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj
index 126b5970dd..13866885f6 100644
--- a/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj
+++ b/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj
@@ -17,8 +17,4 @@
latest
-
-
-
-
diff --git a/src/Tgstation.Server.Host.Watchdog/IsolatedServerFactory.cs b/src/Tgstation.Server.Host.Watchdog/IsolatedServerFactory.cs
index 0b83b829be..654577329b 100644
--- a/src/Tgstation.Server.Host.Watchdog/IsolatedServerFactory.cs
+++ b/src/Tgstation.Server.Host.Watchdog/IsolatedServerFactory.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -13,6 +12,10 @@ namespace Tgstation.Server.Host.Watchdog
///
sealed class IsolatedServerFactory : AssemblyLoadContext, IServerFactory
{
+ const string DllExtension = "dll";
+
+ static readonly string assemblyFileName = String.Join(".", nameof(Tgstation), nameof(Server), nameof(Host), DllExtension);
+
///
/// The path of the to load
///
@@ -22,7 +25,24 @@ namespace Tgstation.Server.Host.Watchdog
/// Construct a
///
/// The value of
- public IsolatedServerFactory(string assemblyPath) => this.assemblyPath = assemblyPath ?? throw new ArgumentNullException(nameof(assemblyPath));
+ public IsolatedServerFactory(string assemblyPath)
+ {
+ this.assemblyPath = assemblyPath ?? throw new ArgumentNullException(nameof(assemblyPath));
+
+ Resolving += IsolatedServerFactory_Resolving;
+ }
+
+ //https://stackoverflow.com/a/40921746/3976486
+ Assembly IsolatedServerFactory_Resolving(AssemblyLoadContext context, AssemblyName assemblyName)
+ {
+ if (assemblyName.Name.EndsWith("resources", StringComparison.Ordinal))
+ return null;
+
+ var foundDll = Directory.GetFileSystemEntries(assemblyPath, String.Join(".", assemblyName.Name, DllExtension), SearchOption.AllDirectories).FirstOrDefault();
+ if (foundDll != default)
+ return context.LoadFromAssemblyPath(foundDll);
+ return context.LoadFromAssemblyName(assemblyName);
+ }
///
/// Loads the at and creates an from it
@@ -32,26 +52,15 @@ namespace Tgstation.Server.Host.Watchdog
/// A new
public IServer CreateServer(string[] args, string updatePath)
{
- //help here: https://stackoverflow.com/questions/40908568/assembly-loading-in-net-core
+ var assembly = LoadFromAssemblyPath(Path.Combine(assemblyPath, assemblyFileName));
- var oldCd = Environment.CurrentDirectory;
- Directory.SetCurrentDirectory(Path.GetDirectoryName(assemblyPath));
- try
- {
- var assembly = LoadFromAssemblyPath(assemblyPath);
+ //find the IServerFactory implementation
+ var serverFactoryInterfaceType = typeof(IServerFactory);
+ var serverFactoryImplementationType = assembly.GetTypes().Where(x => serverFactoryInterfaceType.IsAssignableFrom(x)).First();
- //find the IServerFactory implementation
- var serverFactoryInterfaceType = typeof(IServerFactory);
- var serverFactoryImplementationType = assembly.GetTypes().Where(x => serverFactoryInterfaceType.IsAssignableFrom(x)).First();
+ var serverFactory = (IServerFactory)Activator.CreateInstance(serverFactoryImplementationType);
- var serverFactory = (IServerFactory)Activator.CreateInstance(serverFactoryImplementationType);
-
- return serverFactory.CreateServer(args, updatePath);
- }
- finally
- {
- Directory.SetCurrentDirectory(oldCd);
- }
+ return serverFactory.CreateServer(args, updatePath);
}
//honestly have no idea what this is for, but the examples i see just return null and it seems to work just fine
diff --git a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj
index 0b09864c0e..138e10d50f 100644
--- a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj
+++ b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj
@@ -18,6 +18,7 @@
+
diff --git a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs
index e1bad698f4..a481118eef 100644
--- a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs
+++ b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs
@@ -46,7 +46,6 @@ namespace Tgstation.Server.Host.Watchdog
const string DefaultAssemblyPath = "Default";
var assemblyStoragePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lib");
- var assemblyName = String.Join(".", nameof(Tgstation), nameof(Server), nameof(Host), "dll");
logger.LogInformation("Host watchdog starting...");
@@ -60,7 +59,7 @@ namespace Tgstation.Server.Host.Watchdog
logger.LogTrace("Atttempting to create new server factory...");
Guid updateGuid;
{ //forces serverFactory out of the picture once the scope ends
- var serverFactory = isolatedAssemblyLoader.CreateIsolatedServerFactory(Path.Combine(nextAssemblyPath, assemblyName));
+ var serverFactory = isolatedAssemblyLoader.CreateIsolatedServerFactory(nextAssemblyPath);
using (var server = serverFactory.CreateServer(args, assemblyStoragePath))
{
logger.LogTrace("Running server...");
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index aee2ab7feb..689ee11fba 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -124,7 +124,7 @@ namespace Tgstation.Server.Host.Core
builder.EnableSensitiveDataLogging();
};
- switch (databaseConfiguration.DatabaseType)
+ switch (databaseConfiguration?.DatabaseType ?? DatabaseType.Sqlite)
{
case DatabaseType.MySql:
services.AddDbContext(ConfigureDatabase);
diff --git a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj
index b44b760e2c..6baddb56cb 100644
--- a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj
+++ b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj
@@ -28,6 +28,7 @@
DEBUG;TRACE
prompt
4
+ 7.1
pdbonly
@@ -36,6 +37,7 @@
TRACE
prompt
4
+ 7.1
diff --git a/tgstation-server.sln b/tgstation-server.sln
index 779617bbd2..360c9998b3 100644
--- a/tgstation-server.sln
+++ b/tgstation-server.sln
@@ -102,6 +102,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v4", "v4", "{057FAC33-CC31-
src\DMAPI\tgs\v4\commands.dm = src\DMAPI\tgs\v4\commands.dm
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tgstation.Server.Host.Console.Debug", "src\Tgstation.Server.Host.Console.Debug\Tgstation.Server.Host.Console.Debug.csproj", "{15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -211,6 +213,12 @@ Global
{AA80A190-52E2-4BE3-BFEB-1F148D9E9007}.Docker|Any CPU.Build.0 = Release|Any CPU
{AA80A190-52E2-4BE3-BFEB-1F148D9E9007}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA80A190-52E2-4BE3-BFEB-1F148D9E9007}.Release|Any CPU.Build.0 = Release|Any CPU
+ {15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
+ {15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}.Docker|Any CPU.Build.0 = Debug|Any CPU
+ {15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {15BE5763-DA6F-433F-A4C2-9FCF85F5CC21}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE