feature: first
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 5m31s
Build / Build Nuget package (NuGet) (push) Successful in 6m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 7m25s
Build / Build Launcher (push) Successful in 9m11s
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 5m31s
Build / Build Nuget package (NuGet) (push) Successful in 6m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 7m25s
Build / Build Launcher (push) Successful in 9m11s
This commit is contained in:
27
CringeBootstrap/CringeBootstrap.csproj
Normal file
27
CringeBootstrap/CringeBootstrap.csproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<TieredPGO>true</TieredPGO>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Gameloop.Vdf" Version="0.6.2" />
|
||||
<PackageReference Include="NLog.Schema" Version="5.3.4" />
|
||||
<PackageReference Include="Velopack" Version="0.0.630-g9c52e40" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CringeBootstrap.Abstractions\CringeBootstrap.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\CringeLauncher\CringeLauncher.csproj" ExcludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
67
CringeBootstrap/GameDirectoryAssemblyLoadContext.cs
Normal file
67
CringeBootstrap/GameDirectoryAssemblyLoadContext.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using CringeBootstrap.Abstractions;
|
||||
|
||||
namespace CringeBootstrap;
|
||||
|
||||
public class GameDirectoryAssemblyLoadContext : AssemblyLoadContext, ICoreLoadContext
|
||||
{
|
||||
private static readonly ImmutableHashSet<string> ReferenceAssemblies = ["netstandard"];
|
||||
private readonly Dictionary<string, string> _assemblyNames = [];
|
||||
|
||||
public GameDirectoryAssemblyLoadContext(string dir) : base("CringeBootstrap")
|
||||
{
|
||||
var files = Directory.GetFiles(dir, "*.dll");
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (File.Exists(Path.Join(AppContext.BaseDirectory, Path.GetFileName(file))))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
var name = AssemblyName.GetAssemblyName(file);
|
||||
|
||||
AddOverride(name, file);
|
||||
}
|
||||
catch (BadImageFormatException)
|
||||
{
|
||||
// if we are trying to load native image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOverride(AssemblyName name, string file)
|
||||
{
|
||||
var key = name.Name ?? name.FullName[..','];
|
||||
|
||||
if (key.StartsWith("System.") || ReferenceAssemblies.Contains(key))
|
||||
return;
|
||||
|
||||
_assemblyNames.TryAdd(key, file);
|
||||
}
|
||||
|
||||
public void AddDependencyOverride(string name)
|
||||
{
|
||||
AddOverride(new(name), Path.Join(AppContext.BaseDirectory, name + ".dll"));
|
||||
}
|
||||
|
||||
protected override Assembly? Load(AssemblyName name)
|
||||
{
|
||||
var key = name.Name ?? name.FullName[..','];
|
||||
|
||||
try
|
||||
{
|
||||
return _assemblyNames.TryGetValue(key, out var value) ? LoadFromAssemblyPath(value) : null;
|
||||
}
|
||||
catch (BadImageFormatException e)
|
||||
{
|
||||
Debug.WriteLine(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Assembly? ResolveFromAssemblyName(AssemblyName assemblyName) => Load(assemblyName);
|
||||
public nint ResolveUnmanagedDll(string unmanagedDllName) => LoadUnmanagedDll(unmanagedDllName);
|
||||
}
|
34
CringeBootstrap/NLog.config
Normal file
34
CringeBootstrap/NLog.config
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||
autoReload="true"
|
||||
internalLogLevel="Info">
|
||||
|
||||
<!-- the targets to write to -->
|
||||
<targets>
|
||||
<default-wrapper xsi:type="AsyncWrapper" overflowAction="Block" />
|
||||
|
||||
<!-- write logs to file -->
|
||||
<target xsi:type="File" name="allfile" archiveAboveSize="10485760" fileName="${specialfolder:folder=ApplicationData}/CringeLauncher/logs/log-${shortdate}.log"
|
||||
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${message}" />
|
||||
|
||||
<target xsi:type="File" archiveAboveSize="10485760" name="error" fileName="${specialfolder:folder=ApplicationData}/CringeLauncher/logs/log-error-${shortdate}.log"
|
||||
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${message} ${cringe-exception}" />
|
||||
|
||||
<target name="debugger" xsi:type="Debugger" layout="${message} ${cringe-exception}"/>
|
||||
|
||||
<target xsi:type="ColoredConsole" name="console" layout="[${longdate}] ${uppercase:${level}}: ${message} ${cringe-exception}" />
|
||||
</targets>
|
||||
|
||||
<!-- rules to map from logger name to target -->
|
||||
<rules>
|
||||
<logger name="*" level="Info,Error,Fatal" writeTo="allfile,debugger,console" />
|
||||
<logger name="*" level="Debug" writeTo="debugger" />
|
||||
<logger name="*" level="Error" writeTo="error,debugger" />
|
||||
</rules>
|
||||
</nlog>
|
||||
|
||||
</configuration>
|
55
CringeBootstrap/Program.cs
Normal file
55
CringeBootstrap/Program.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Web;
|
||||
using CringeBootstrap;
|
||||
using CringeBootstrap.Abstractions;
|
||||
using Velopack;
|
||||
|
||||
#if DEBUG
|
||||
while (!Debugger.IsAttached)
|
||||
Thread.Sleep(100);
|
||||
#endif
|
||||
|
||||
VelopackApp.Build().Run();
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
var path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CringeLauncher",
|
||||
"current", "CringeBootstrap.exe");
|
||||
|
||||
Console.Write("Set your Launch Options under ");
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.Write("Space Engineers -> Properties -> Launch Options");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine(" in steam and launch the game as usual");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine($"\"{path}\" %command%");
|
||||
Console.ResetColor();
|
||||
Console.Read();
|
||||
return;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
AssemblyLoadContext.Default.Resolving += (loadContext, name) =>
|
||||
{
|
||||
Debug.WriteLine($"resolving {name} in {loadContext}");
|
||||
return null;
|
||||
};
|
||||
#endif
|
||||
|
||||
var dir = Path.GetDirectoryName(args[0])!;
|
||||
var context = new GameDirectoryAssemblyLoadContext(dir);
|
||||
|
||||
// a list of assemblies which are not in the game binaries but reference them
|
||||
context.AddDependencyOverride("CringeLauncher");
|
||||
context.AddDependencyOverride("CringePlugins");
|
||||
|
||||
var launcher = context.LoadFromAssemblyName(new AssemblyName("CringeLauncher"));
|
||||
|
||||
using var corePlugin = (ICorePlugin) launcher.CreateInstance("CringeLauncher.Launcher")!;
|
||||
|
||||
corePlugin.Initialize(args);
|
||||
corePlugin.Run();
|
2204
CringeBootstrap/packages.lock.json
Normal file
2204
CringeBootstrap/packages.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user