Skip to content

Commit

Permalink
Merge pull request Squirrel#1667 from johan-lindqvist/branches/exe-fi…
Browse files Browse the repository at this point in the history
…les-not-removed-during-uninstall

Fix issue where exe files were not removed during uninstall.
  • Loading branch information
anaisbetts authored Oct 31, 2020
2 parents 7d769c7 + c982449 commit 45834cb
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/Squirrel/SquirrelAwareExecutableDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,26 @@ public static List<string> GetAllSquirrelAwareApps(string directory, int minimum
static int? GetAssemblySquirrelAwareVersion(string executable)
{
try {
var assembly = AssemblyDefinition.ReadAssembly(executable);
if (!assembly.HasCustomAttributes) return null;
using (var assembly = AssemblyDefinition.ReadAssembly(executable)) {
if (!assembly.HasCustomAttributes) return null;

var attrs = assembly.CustomAttributes;
var attribute = attrs.FirstOrDefault(x => {
if (x.AttributeType.FullName != typeof(AssemblyMetadataAttribute).FullName) return false;
if (x.ConstructorArguments.Count != 2) return false;
return x.ConstructorArguments[0].Value.ToString() == "SquirrelAwareVersion";
});
var attrs = assembly.CustomAttributes;
var attribute = attrs.FirstOrDefault(x => {
if (x.AttributeType.FullName != typeof(AssemblyMetadataAttribute).FullName) return false;
if (x.ConstructorArguments.Count != 2) return false;
return x.ConstructorArguments[0].Value.ToString() == "SquirrelAwareVersion";
});

if (attribute == null) return null;
if (attribute == null) return null;

int result;
if (!Int32.TryParse(attribute.ConstructorArguments[1].Value.ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out result)) {
return null;
}
int result;
if (!Int32.TryParse(attribute.ConstructorArguments[1].Value.ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out result)) {
return null;
}

return result;
}
return result;
}
}
catch (FileLoadException) { return null; }
catch (BadImageFormatException) { return null; }
}
Expand Down

0 comments on commit 45834cb

Please sign in to comment.