diff --git a/IPA/Program.cs b/IPA/Program.cs index 05c6abb7..75b3c3ad 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -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 diff --git a/IPA/Properties/AssemblyInfo.cs b/IPA/Properties/AssemblyInfo.cs index 9769ae7e..2bccbb3e 100644 --- a/IPA/Properties/AssemblyInfo.cs +++ b/IPA/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file +[assembly: AssemblyVersion(Program.FileVersion)] +[assembly: AssemblyFileVersion(Program.FileVersion)] \ No newline at end of file diff --git a/Refs/UnityEngine.CoreModule.dll b/Refs/UnityEngine.CoreModule.dll index 3c6b6316..f6478af7 100644 Binary files a/Refs/UnityEngine.CoreModule.dll and b/Refs/UnityEngine.CoreModule.dll differ