mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-10 13:44:22 +00:00
Get rid of ILMerge, use more friendly ILBundle
This commit is contained in:
56
packages/ILBundle.1.0.0.14/Content/ILBundle.cs.pp
vendored
Normal file
56
packages/ILBundle.1.0.0.14/Content/ILBundle.cs.pp
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace $rootnamespace$
|
||||
{
|
||||
public static class ILBundle
|
||||
{
|
||||
public static List<String> ResourceNames = new List<string>();
|
||||
public static Assembly ExecutingAssembly;
|
||||
|
||||
static ILBundle()
|
||||
{
|
||||
ExecutingAssembly = Assembly.GetExecutingAssembly();
|
||||
ResourceNames = ExecutingAssembly.GetManifestResourceNames().Where(n => n.EndsWith(".dll") || n.EndsWith(".exe")).ToList();
|
||||
}
|
||||
|
||||
public static void RegisterAssemblyResolver()
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (s, assembly) =>
|
||||
{
|
||||
var assemblyName = new AssemblyName(assembly.Name);
|
||||
var paths = new List<string>{
|
||||
string.Format("{0}.dll", assemblyName.Name),
|
||||
string.Format("{0}.exe", assemblyName.Name)
|
||||
};
|
||||
|
||||
foreach(var path in paths)
|
||||
{
|
||||
if (ResourceNames.Contains(path))
|
||||
{
|
||||
using (var stream = ExecutingAssembly.GetManifestResourceStream(path))
|
||||
{
|
||||
if (stream == null)
|
||||
return null;
|
||||
|
||||
var bytes = new byte[stream.Length];
|
||||
stream.Read(bytes, 0, bytes.Length);
|
||||
try
|
||||
{
|
||||
return Assembly.Load(bytes);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.Print("Failed to load: {0}, Exception: {1}", path, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
9
packages/ILBundle.1.0.0.14/Content/ILBundle.targets
vendored
Normal file
9
packages/ILBundle.1.0.0.14/Content/ILBundle.targets
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="AfterResolveReferences">
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
|
||||
<LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user