示例#1
0
        public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
        {
            try
            {
                AnsiConsole.MarkupLine("[cyan]-=[[ EscapeFromTarkov-Trainer Universal Installer ]]=-[/]");
                AnsiConsole.WriteLine();

                var installation = Installation.GetTargetInstallation(settings.Path, "Please select from where to uninstall the trainer");
                if (installation == null)
                {
                    return((int)ExitCode.NoInstallationFound);
                }

                AnsiConsole.MarkupLine($"Target [green]EscapeFromTarkov ({installation.Version})[/] in [blue]{installation.Location}[/].");

                if (!RemoveFile(Path.Combine(installation.Managed, "NLog.EFT.Trainer.dll")))
                {
                    return((int)ExitCode.RemoveDllFailed);
                }

                if (!RemoveFile(Path.Combine(installation.Data, "outline")))
                {
                    return((int)ExitCode.RemoveOutlineFailed);
                }

                RemoveOrPatchConfiguration(installation);
            }
            catch (Exception ex)
            {
                AnsiConsole.MarkupLine($"[red]Error: {ex.Message}. Please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                return((int)ExitCode.Failure);
            }

            return((int)ExitCode.Success);
        }
示例#2
0
        public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
        {
            try
            {
                AnsiConsole.MarkupLine("-=[[ [cyan]EscapeFromTarkov-Trainer Universal Installer[/] - [blue]https://github.com/sailro [/]]]=-");
                AnsiConsole.WriteLine();

                var installation = Installation.GetTargetInstallation(settings.Path, "Please select from where to uninstall the trainer");
                if (installation == null)
                {
                    return((int)ExitCode.NoInstallationFound);
                }

                AnsiConsole.MarkupLine($"Target [green]EscapeFromTarkov ({installation.Version})[/] in [blue]{installation.Location.EscapeMarkup()}[/].");

                if (!RemoveFile(Path.Combine(installation.Managed, "NLog.EFT.Trainer.dll")))
                {
                    return((int)ExitCode.RemoveDllFailed);
                }

                // MonoMod.RuntimeDetour is a dependency used by the non-ilmerged 0Harmony.dll used by legacy spt-aki. In this case we are not handling the removal
                if (!File.Exists(Path.Combine(installation.Managed, "MonoMod.RuntimeDetour.dll")))
                {
                    if (!RemoveFile(Path.Combine(installation.Managed, "0Harmony.dll")))
                    {
                        return((int)ExitCode.RemoveHarmonyDllFailed);
                    }
                }

                if (!RemoveFile(Path.Combine(installation.Data, "outline")))
                {
                    return((int)ExitCode.RemoveOutlineFailed);
                }

                RemoveOrPatchConfiguration(installation);
            }
            catch (Exception ex)
            {
                AnsiConsole.MarkupLine($"[red]Error: {ex.Message.EscapeMarkup()}. Please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                return((int)ExitCode.Failure);
            }

            return((int)ExitCode.Success);
        }
示例#3
0
        public override async Task <int> ExecuteAsync(CommandContext context, Settings settings)
        {
            try
            {
                AnsiConsole.MarkupLine("[cyan]-=[[ EscapeFromTarkov-Trainer Universal Installer ]]=-[/]");
                AnsiConsole.WriteLine();

                var installation = Installation.GetTargetInstallation(settings.Path, "Please select where to install the trainer");
                if (installation == null)
                {
                    return((int)ExitCode.NoInstallationFound);
                }

                AnsiConsole.MarkupLine($"Target [green]EscapeFromTarkov ({installation.Version})[/] in [blue]{installation.Location}[/].");

                var(compilation, archive) = await GetCompilationAsync(installation, "master");

                if (compilation == null)
                {
                    var branch = settings.Branch ?? installation.Version.ToString();
                    if (!branch.StartsWith("dev-"))
                    {
                        branch = "dev-" + branch;
                    }

                    (compilation, archive) = await GetCompilationAsync(installation, branch);
                }

                if (compilation == null)
                {
                    AnsiConsole.MarkupLine($"[red]Unable to compile trainer for version {installation.Version}. Please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                    return((int)ExitCode.CompilationFailed);
                }

                if (installation.UsingSptAki)
                {
                    AnsiConsole.MarkupLine("[yellow]SPT-AKI detected. Please make sure you have run the game at least once before installing the trainer.[/]");
                    AnsiConsole.MarkupLine("[yellow]SPT-AKI is patching binaries during the first run, and we [underline]need[/] to compile against those patched binaries.[/]");
                    AnsiConsole.MarkupLine("[yellow]If you install this trainer on stock binaries, the game will freeze at the startup screen.[/]");

                    if (!AnsiConsole.Confirm("Continue installation (yes I have run the game at least once) ?"))
                    {
                        return((int)ExitCode.Canceled);
                    }
                }

                if (!CreateDll(installation, compilation))
                {
                    return((int)ExitCode.CreateDllFailed);
                }

                if (!CreateOutline(installation, archive !))
                {
                    return((int)ExitCode.CreateOutlineFailed);
                }

                CreateOrPatchConfiguration(installation);
            }
            catch (Exception ex)
            {
                AnsiConsole.MarkupLine($"[red]Error: {ex.Message}. Please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                return((int)ExitCode.Failure);
            }

            return((int)ExitCode.Success);
        }
示例#4
0
        public override async Task <int> ExecuteAsync(CommandContext context, Settings settings)
        {
            try
            {
                AnsiConsole.MarkupLine("-=[[ [cyan]EscapeFromTarkov-Trainer Universal Installer[/] - [blue]https://github.com/sailro [/]]]=-");
                AnsiConsole.WriteLine();

                var installation = Installation.GetTargetInstallation(settings.Path, "Please select where to install the trainer");
                if (installation == null)
                {
                    return((int)ExitCode.NoInstallationFound);
                }

                AnsiConsole.MarkupLine($"Target [green]EscapeFromTarkov ({installation.Version})[/] in [blue]{installation.Location.EscapeMarkup()}[/].");

                // Try first to compile against master
                var @try = 0;
                var(compilation, archive, errors) = await GetCompilationAsync(++@try, installation, "master");

                var files = errors
                            .Select(d => d.Location.SourceTree?.FilePath)
                            .Where(s => s is not null)
                            .Distinct()
                            .ToArray();

                if (compilation == null)
                {
                    // Failure, so try with a dedicated branch if exists
                    var branch = settings.Branch ?? installation.Version.ToString();
                    if (!branch.StartsWith("dev-"))
                    {
                        branch = "dev-" + branch;
                    }

                    (compilation, archive, _) = await GetCompilationAsync(++@try, installation, branch);
                }

                if (compilation == null && files.Any() && files.All(f => f !.StartsWith("Features")))
                {
                    // Failure, retry by removing faulting features if possible
                    AnsiConsole.MarkupLine($"[yellow]Trying to disable faulting feature(s): [red]{string.Join(", ", files.Select(Path.GetFileNameWithoutExtension))}[/].[/]");
                    (compilation, archive, errors) = await GetCompilationAsync(++@try, installation, "master", files !);

                    if (!errors.Any())
                    {
                        AnsiConsole.MarkupLine("[yellow]We found a fallback! But please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                    }
                }

                if (compilation == null)
                {
                    // Failure
                    AnsiConsole.MarkupLine($"[red]Unable to compile trainer for version {installation.Version}. Please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                    return((int)ExitCode.CompilationFailed);
                }

                if (installation.UsingSptAki)
                {
                    AnsiConsole.MarkupLine("[yellow]SPT-AKI detected. Please make sure you have run the game at least once before installing the trainer.[/]");
                    AnsiConsole.MarkupLine("[yellow]SPT-AKI is patching binaries during the first run, and we [underline]need[/] to compile against those patched binaries.[/]");
                    AnsiConsole.MarkupLine("[yellow]If you install this trainer on stock binaries, the game will freeze at the startup screen.[/]");

                    if (!AnsiConsole.Confirm("Continue installation (yes I have run the game at least once) ?"))
                    {
                        return((int)ExitCode.Canceled);
                    }
                }

                if (!CreateDll(installation, "NLog.EFT.Trainer.dll", (dllPath) => compilation.Emit(dllPath)))
                {
                    return((int)ExitCode.CreateDllFailed);
                }

                if (!CreateDll(installation, "0Harmony.dll", (dllPath) => File.WriteAllBytes(dllPath, Resources._0Harmony), false))
                {
                    return((int)ExitCode.CreateHarmonyDllFailed);
                }

                if (!CreateOutline(installation, archive !))
                {
                    return((int)ExitCode.CreateOutlineFailed);
                }

                CreateOrPatchConfiguration(installation);
            }
            catch (Exception ex)
            {
                AnsiConsole.MarkupLine($"[red]Error: {ex.Message.EscapeMarkup()}. Please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]");
                return((int)ExitCode.Failure);
            }

            return((int)ExitCode.Success);
        }