Browse Source

Made installer check currently installed version so as not to overwrite newer versions

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
3a2fe9f344
3 changed files with 56 additions and 33 deletions
  1. +52
    -30
      IPA/Program.cs
  2. +4
    -3
      IPA/Properties/AssemblyInfo.cs
  3. BIN
      Refs/UnityEngine.CoreModule.dll

+ 52
- 30
IPA/Program.cs View File

@ -23,6 +23,8 @@ namespace IPA
Unknown
}
public const string FileVersion = "3.12.10";
public static Version Version => Assembly.GetEntryAssembly().GetName().Version;
public static readonly ArgumentFlag ArgHelp = new ArgumentFlag("--help", "-h") { DocString = "prints this message" };
@ -138,36 +140,56 @@ namespace IPA
{
try
{
var backup = new BackupUnit(context);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Restoring old version... ");
if (BackupManager.HasBackup(context))
BackupManager.Restore(context);
var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins");
bool isFlat = Directory.Exists(nativePluginFolder) &&
Directory.GetFiles(nativePluginFolder).Any(f => f.EndsWith(".dll"));
bool force = !BackupManager.HasBackup(context) || ArgForce;
var architecture = DetectArchitecture(context.Executable);
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("Installing files... ");
CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force,
backup,
(from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat,
architecture));
CopyAll(new DirectoryInfo(context.LibsPathSrc), new DirectoryInfo(context.LibsPathDst), force,
backup,
(from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat,
architecture));
CopyAll(new DirectoryInfo(context.IPARoot), new DirectoryInfo(context.ProjectRoot), force,
backup,
null, false);
//backup.Add(context.AssemblyFile);
//backup.Add(context.EngineFile);
bool installFiles = true;
// first, check currently installed version, if any
if (File.Exists(Path.Combine(context.ProjectRoot, "winhttp.dll")))
{ // installed, so check version of installed assembly
string injectorPath = Path.Combine(context.ManagedPath, "IPA.Injector.dll");
if (File.Exists(injectorPath))
{
var verInfo = FileVersionInfo.GetVersionInfo(injectorPath);
var fileVersion = new Version(verInfo.FileVersion);
if (fileVersion > Version)
installFiles = false;
}
}
if (installFiles || ArgForce)
{
var backup = new BackupUnit(context);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Restoring old version... ");
if (BackupManager.HasBackup(context))
BackupManager.Restore(context);
var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins");
bool isFlat = Directory.Exists(nativePluginFolder) &&
Directory.GetFiles(nativePluginFolder).Any(f => f.EndsWith(".dll"));
bool force = !BackupManager.HasBackup(context) || ArgForce;
var architecture = DetectArchitecture(context.Executable);
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("Installing files... ");
CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force,
backup,
(from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat,
architecture));
CopyAll(new DirectoryInfo(context.LibsPathSrc), new DirectoryInfo(context.LibsPathDst), force,
backup,
(from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat,
architecture));
CopyAll(new DirectoryInfo(context.IPARoot), new DirectoryInfo(context.ProjectRoot), force,
backup,
null, false);
}
else
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Not copying files because newer version already installed");
}
#region Create Plugin Folder


+ 4
- 3
IPA/Properties/AssemblyInfo.cs View File

@ -1,4 +1,5 @@
using System.Reflection;
using IPA;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -31,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.12.10")]
[assembly: AssemblyFileVersion("3.12.10")]
[assembly: AssemblyVersion(Program.FileVersion)]
[assembly: AssemblyFileVersion(Program.FileVersion)]

BIN
Refs/UnityEngine.CoreModule.dll View File


Loading…
Cancel
Save