mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
ReflectionLoadFile also loads into the AppDomain 👨🔫
We need to examine the file without it being loaded into our AppDomain or else all kinds of badness happens. Instead, use Cecil to load the assembly
This commit is contained in:
@@ -45,6 +45,18 @@
|
||||
<Reference Include="Microsoft.Web.XmlTransform">
|
||||
<HintPath>..\..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil">
|
||||
<HintPath>..\..\packages\Mono.Cecil.0.9.5.4\lib\net40\Mono.Cecil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb">
|
||||
<HintPath>..\..\packages\Mono.Cecil.0.9.5.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb">
|
||||
<HintPath>..\..\packages\Mono.Cecil.0.9.5.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks">
|
||||
<HintPath>..\..\packages\Mono.Cecil.0.9.5.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Core, Version=2.8.50506.491, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\NuGet.Core.2.8.2\lib\net40-Client\NuGet.Core.dll</HintPath>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace Squirrel
|
||||
{
|
||||
@@ -35,11 +36,13 @@ namespace Squirrel
|
||||
{
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.ReflectionOnlyLoadFrom(executable);
|
||||
var attrs = assembly.GetCustomAttributesData();
|
||||
var assembly = AssemblyDefinition.ReadAssembly(executable);
|
||||
if (!assembly.HasCustomAttributes) return null;
|
||||
|
||||
var attrs = assembly.CustomAttributes;
|
||||
var attribute = attrs.FirstOrDefault(x =>
|
||||
{
|
||||
if (x.AttributeType != typeof(AssemblyMetadataAttribute)) return false;
|
||||
if (x.AttributeType.FullName != typeof(AssemblyMetadataAttribute).FullName) return false;
|
||||
if (x.ConstructorArguments.Count != 2) return false;
|
||||
return x.ConstructorArguments[0].Value.ToString() == "SquirrelAwareVersion";
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net45" />
|
||||
<package id="Mono.Cecil" version="0.9.5.4" targetFramework="net45" />
|
||||
<package id="NuGet.Core" version="2.8.2" targetFramework="net45" />
|
||||
<package id="Splat" version="1.4.0" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user