Browse Source

Added --version to installer

pull/53/head
Anairkoen Schno 3 years ago
parent
commit
18d39fd8b9
Signed by: DaNike GPG Key ID: BEFB74D5F3FC4387
4 changed files with 51 additions and 18 deletions
  1. +1
    -1
      IPA.Loader/Config/SelfConfig.cs
  2. +1
    -0
      IPA.Loader/Loader/PluginLoader.cs
  3. +1
    -1
      IPA.Loader/Loader/manifest.json
  4. +48
    -16
      IPA/Program.cs

+ 1
- 1
IPA.Loader/Config/SelfConfig.cs View File

@ -68,7 +68,7 @@ namespace IPA.Config
}
internal const string IPAName = "Beat Saber IPA";
internal const string IPAVersion = "4.1.2.0";
internal const string IPAVersion = "4.1.3.0";
// uses Updates.AutoUpdate, Updates.AutoCheckUpdates, YeetMods, Debug.ShowCallSource, Debug.ShowDebug,
// Debug.CondenseModLogs


+ 1
- 0
IPA.Loader/Loader/PluginLoader.cs View File

@ -104,6 +104,7 @@ namespace IPA.Loader
Logger.loader.Critical("Error loading own manifest");
Logger.loader.Critical(e);
}
var resolver = new CecilLibLoader();
resolver.AddSearchDirectory(UnityGame.LibraryPath);
resolver.AddSearchDirectory(UnityGame.PluginsPath);


+ 1
- 1
IPA.Loader/Loader/manifest.json View File

@ -8,7 +8,7 @@
"gameVersion": "1.11.1",
"id": "BSIPA",
"name": "Beat Saber IPA",
"version": "4.1.2",
"version": "4.1.3",
"icon": "IPA.icon_white.png",
"features": {
"IPA.DefineFeature": {


+ 48
- 16
IPA/Program.cs View File

@ -23,11 +23,12 @@ namespace IPA
Unknown
}
public const string FileVersion = "4.1.2.0";
public const string FileVersion = "4.1.3.0";
public static Version Version => Assembly.GetEntryAssembly().GetName().Version;
public static readonly ArgumentFlag ArgHelp = new ArgumentFlag("--help", "-h") { DocString = "prints this message" };
public static readonly ArgumentFlag ArgVersion = new ArgumentFlag("--version", "-v") { DocString = "prints the version that will be installed and is currently installed" };
public static readonly ArgumentFlag ArgWaitFor = new ArgumentFlag("--waitfor", "-w") { DocString = "waits for the specified PID to exit", ValueString = "PID" };
public static readonly ArgumentFlag ArgForce = new ArgumentFlag("--force", "-f") { DocString = "forces the operation to go through" };
public static readonly ArgumentFlag ArgRevert = new ArgumentFlag("--revert", "-r") { DocString = "reverts the IPA installation" };
@ -39,7 +40,7 @@ namespace IPA
[STAThread]
public static void Main()
{
Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch, ArgNoRevert).Process();
Arguments.CmdLine.Flags(ArgHelp, ArgVersion, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch, ArgNoRevert).Process();
if (ArgHelp)
{
@ -47,9 +48,14 @@ namespace IPA
return;
}
if (ArgVersion)
{
Console.WriteLine($"BSIPA Installer version {Version}");
}
try
{
if (ArgWaitFor.HasValue)
if (ArgWaitFor.HasValue && !ArgVersion)
{ // wait for process if necessary
var pid = int.Parse(ArgWaitFor.Value);
@ -77,7 +83,7 @@ namespace IPA
// ReSharper enable AccessToModifiedClosure
var asmName = new AssemblyName(e.Name);
var testFile = Path.Combine(libsDir, $"{asmName.Name}.{asmName.Version}.dll");
var testFile = Path.Combine(libsDir, $"{asmName.Name}.dll");
if (File.Exists(testFile))
return Assembly.LoadFile(testFile);
@ -96,6 +102,17 @@ namespace IPA
else
context = PatchContext.Create(argExeName);
if (ArgVersion)
{
var installed = GetInstalledVersion(context);
if (installed == null)
Console.WriteLine("No currently installed version");
else
Console.WriteLine($"Installed version: {installed}");
return;
}
// Sanitizing
Validate(context);
@ -109,6 +126,11 @@ namespace IPA
}
catch (Exception e)
{
if (ArgVersion)
{
Console.WriteLine("No currently installed version");
return;
}
Fail(e.Message);
}
@ -136,24 +158,34 @@ namespace IPA
}
}
private static Version GetInstalledVersion(PatchContext context)
{
// 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);
return fileVersion;
}
}
return null;
}
private static void Install(PatchContext context)
{
try
{
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;
}
}
var fileVersion = GetInstalledVersion(context);
if (fileVersion != null && fileVersion > Version)
installFiles = false;
if (installFiles || ArgForce)
{


Loading…
Cancel
Save