Merge pull request #3036 from sbwalker/dev

Added logic to ensure assembly version being installed is equal to or greater than existing assembly
This commit is contained in:
Shaun Walker 2023-07-17 08:16:16 -04:00 committed by GitHub
commit 96e7178cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -201,8 +201,25 @@ namespace Oqtane.Infrastructure
{
Directory.CreateDirectory(Path.GetDirectoryName(filename));
}
if (Path.Exists(filename) && Path.GetExtension(filename).ToLower() == ".dll")
{
// ensure assembly version is equal to or greater than existing assembly
var assembly = filename.Replace(Path.GetFileName(filename), "temp.dll");
entry.ExtractToFile(assembly, true);
if (Version.Parse(FileVersionInfo.GetVersionInfo(assembly).FileVersion).CompareTo(Version.Parse(FileVersionInfo.GetVersionInfo(filename).FileVersion)) >= 0)
{
File.Move(assembly, filename, true);
}
else
{
File.Delete(assembly);
}
}
else
{
entry.ExtractToFile(filename, true);
}
}
catch
{
// an error occurred extracting the file