mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Get rid of ILMerge, use more friendly ILBundle
This commit is contained in:
parent
c09af9b937
commit
43264e77b2
11 changed files with 153 additions and 3 deletions
|
@ -93,6 +93,7 @@
|
|||
<Compile Include="CardsFarmer.cs" />
|
||||
<Compile Include="CMsgClientClanInviteAction.cs" />
|
||||
<Compile Include="Debugging.cs" />
|
||||
<Compile Include="ILBundle.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@ -104,6 +105,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="ILBundle.targets" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -141,12 +143,12 @@
|
|||
<PropertyGroup>
|
||||
<PostBuildEvent Condition=" '$(OS)' != 'Unix' ">if $(ConfigurationName) == Release (
|
||||
mkdir "$(TargetDir)out" "$(TargetDir)out\config"
|
||||
copy "$(TargetDir)$(TargetName).exe" "$(TargetDir)out\ASF.exe"
|
||||
copy "$(TargetDir)config\example.xml" "$(TargetDir)out\config"
|
||||
copy "$(TargetDir)config\minimal.xml" "$(TargetDir)out\config"
|
||||
"$(SolutionDir)tools\ILMerge.exe" /out:"$(TargetDir)out\ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll" /target:exe /targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319 /wildcards
|
||||
del "$(TargetDir)out\ASF.pdb"
|
||||
)</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="ILBundle.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
45
ArchiSteamFarm/ILBundle.cs
Normal file
45
ArchiSteamFarm/ILBundle.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
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
ArchiSteamFarm/ILBundle.targets
Normal file
9
ArchiSteamFarm/ILBundle.targets
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>
|
|
@ -53,7 +53,6 @@ namespace ArchiSteamFarm {
|
|||
private static readonly string ExecutablePath = Assembly.Location;
|
||||
private static readonly AssemblyName AssemblyName = Assembly.GetName();
|
||||
private static readonly object ConsoleLock = new object();
|
||||
//private static readonly string ExeName = AssemblyName.Name + ".exe";
|
||||
|
||||
internal static readonly uint UniqueID = (uint) Utilities.Random.Next();
|
||||
internal static readonly string Version = AssemblyName.Version.ToString();
|
||||
|
@ -159,6 +158,7 @@ namespace ArchiSteamFarm {
|
|||
private static void Main(string[] args) {
|
||||
Logging.LogGenericInfo("Main", "Archi's Steam Farm, version " + Version);
|
||||
|
||||
ILBundle.RegisterAssemblyResolver();
|
||||
InitServices();
|
||||
|
||||
Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="HtmlAgilityPack" version="1.4.9" targetFramework="net45" />
|
||||
<package id="ILBundle" version="1.0.0.14" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="8.0.1-beta3" targetFramework="net45" />
|
||||
<package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
|
||||
<package id="SteamKit2" version="1.6.5" targetFramework="net45" />
|
||||
|
|
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>
|
BIN
packages/ILBundle.1.0.0.14/ILBundle.1.0.0.14.nupkg
vendored
Normal file
BIN
packages/ILBundle.1.0.0.14/ILBundle.1.0.0.14.nupkg
vendored
Normal file
Binary file not shown.
11
packages/ILBundle.1.0.0.14/Tools/Net40/Uninstall.ps1
vendored
Normal file
11
packages/ILBundle.1.0.0.14/Tools/Net40/Uninstall.ps1
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
#http://blogs.clariusconsulting.net/kzu/how-to-add-an-msbuild-import-to-a-project-on-nuget-install/
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
# Need to load MSBuild assembly if it’s not loaded yet.
|
||||
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
|
||||
# Grab the loaded MSBuild project for the project
|
||||
$msbuild = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
|
||||
$importToRemove = $msbuild.Xml.Imports | Where-Object { $_.Project.Endswith('ILBundle.targets') }
|
||||
# Remove the import and save the project
|
||||
$msbuild.Xml.RemoveChild($importToRemove) | out-null
|
||||
$project.Save()
|
17
packages/ILBundle.1.0.0.14/Tools/Net40/install.ps1
vendored
Normal file
17
packages/ILBundle.1.0.0.14/Tools/Net40/install.ps1
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# http://blogs.clariusconsulting.net/kzu/how-to-add-an-msbuild-import-to-a-project-on-nuget-install/
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
# This is the MSBuild targets file to add
|
||||
$targetsFile = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FileName), 'ILBundle.targets')
|
||||
# Need to load MSBuild assembly if it's not loaded yet.
|
||||
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
|
||||
# Grab the loaded MSBuild project for the project
|
||||
$msbuild = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
|
||||
|
||||
# Make the path to the targets file relative.
|
||||
$projectUri = new-object Uri('file://' + $project.FullName)
|
||||
$targetUri = new-object Uri('file://' + $targetsFile)
|
||||
$relativePath = $projectUri.MakeRelativeUri($targetUri).ToString().Replace([System.IO.Path]::AltDirectorySeparatorChar, [System.IO.Path]::DirectorySeparatorChar)
|
||||
|
||||
# Add the import and save the project
|
||||
$msbuild.Xml.AddImport($relativePath) | out-null
|
||||
$project.Save()
|
Binary file not shown.
Loading…
Reference in a new issue