From 51c6394b5535c2f9d22f340ee1e7aaa5be945642 Mon Sep 17 00:00:00 2001 From: Paulov Date: Tue, 7 May 2024 17:33:50 +0100 Subject: [PATCH 1/2] Fix the InstallerService not supporting changes to StayInTarkov-Release.zip --- .../Services/Install/InstallerService.cs | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/SIT.Manager/Services/Install/InstallerService.cs b/SIT.Manager/Services/Install/InstallerService.cs index 9ab65927..efd6c0a3 100644 --- a/SIT.Manager/Services/Install/InstallerService.cs +++ b/SIT.Manager/Services/Install/InstallerService.cs @@ -1,4 +1,5 @@ using FluentAvalonia.UI.Controls; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Extensions.Logging; using SIT.Manager.Interfaces; using SIT.Manager.Models; @@ -653,23 +654,17 @@ public async Task InstallSit(GithubRelease selectedVersion, string targetInstall CleanUpEFTDirectory(); } - string sitReleaseZipPath = Path.Combine(targetInstallDir, "SITLauncher", "CoreFiles", "StayInTarkov-Release.zip"); - if (File.Exists(sitReleaseZipPath)) - { - File.Delete(sitReleaseZipPath); - } + var coreFilesPath = Path.Combine(targetInstallDir, "SITLauncher", "CoreFiles"); + + // Recursively delete all downloaded files / folders + Directory.Delete(coreFilesPath, true); + // Recreate directory for downloaded files / folders + Directory.CreateDirectory(coreFilesPath); - string coreFilesPath = Path.Combine(targetInstallDir, "SITLauncher", "CoreFiles"); - if (!Directory.Exists(coreFilesPath)) - { - Directory.CreateDirectory(coreFilesPath); - } string backupCoreFilesPath = Path.Combine(targetInstallDir, "SITLauncher", "Backup", "CoreFiles"); if (!Directory.Exists(backupCoreFilesPath)) - { Directory.CreateDirectory(backupCoreFilesPath); - } string pluginsPath = Path.Combine(targetInstallDir, "BepInEx", "plugins"); Directory.CreateDirectory(pluginsPath); @@ -702,17 +697,40 @@ public async Task InstallSit(GithubRelease selectedVersion, string targetInstall await _fileService.ExtractArchive(Path.Combine(coreFilesPath, "StayInTarkov-Release.zip"), coreFilesPath, internalExtractionProgress); } + // Find Assembly-CSharp file + var assemblyCSharpFiles = Directory.GetFiles(coreFilesPath, "Assembly-CSharp.dll"); + if (assemblyCSharpFiles.Length == 0) + throw new IndexOutOfRangeException("No Assembly-CSharp found in download!"); + if (assemblyCSharpFiles.Length > 1) + throw new IndexOutOfRangeException("There are more than one Assembly-CSharp files found!"); + + // Find StayInTarkov.dll + var sitFiles = Directory.GetFiles(coreFilesPath, "StayInTarkov.dll"); + if (sitFiles.Length == 0) + throw new IndexOutOfRangeException("No StayInTarkov.dll found in download!"); + if (sitFiles.Length > 1) + throw new IndexOutOfRangeException("There are more than one StayInTarkov.dll files found!"); + + // Find SIT.WildSpawnType.PrePatcher.dll + var prePatcherFiles = Directory.GetFiles(coreFilesPath, "*PrePatch*"); + string eftDataManagedPath = Path.Combine(targetInstallDir, "EscapeFromTarkov_Data", "Managed"); if (File.Exists(Path.Combine(eftDataManagedPath, "Assembly-CSharp.dll"))) { File.Copy(Path.Combine(eftDataManagedPath, "Assembly-CSharp.dll"), Path.Combine(backupCoreFilesPath, "Assembly-CSharp.dll"), true); } - File.Copy(Path.Combine(coreFilesPath, "StayInTarkov-Release", "Assembly-CSharp.dll"), Path.Combine(eftDataManagedPath, "Assembly-CSharp.dll"), true); - File.Copy(Path.Combine(coreFilesPath, "StayInTarkov-Release", "StayInTarkov.dll"), Path.Combine(pluginsPath, "StayInTarkov.dll"), true); - var downloadedPrePatcherPath = Path.Combine(coreFilesPath, "StayInTarkov-Release", "SIT.WildSpawnType.PrePatcher.dll"); - if (File.Exists(downloadedPrePatcherPath)) - File.Copy(downloadedPrePatcherPath, Path.Combine(patchersPath, "SIT.WildSpawnType.PrePatcher.dll"), true); + if(Directory.Exists(eftDataManagedPath)) + File.Copy(assemblyCSharpFiles[0], Path.Combine(eftDataManagedPath, "Assembly-CSharp.dll"), true); + + if(Directory.Exists(pluginsPath)) + File.Copy(sitFiles[0], Path.Combine(pluginsPath, "StayInTarkov.dll"), true); + + foreach (var ppFI in prePatcherFiles.Select(x => new FileInfo(x))) + { + var ppFilePath = ppFI.Name; + File.Copy(ppFI.FullName, Path.Combine(patchersPath, ppFilePath), true); + } using (Stream? resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("SIT.Manager.Resources.Aki.Common.dll")) { From 035cfa178bf65ca1e04b9537897c00e9e30b88a3 Mon Sep 17 00:00:00 2001 From: Paulov Date: Tue, 7 May 2024 17:37:09 +0100 Subject: [PATCH 2/2] Add missing search asterisks --- SIT.Manager/Services/Install/InstallerService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SIT.Manager/Services/Install/InstallerService.cs b/SIT.Manager/Services/Install/InstallerService.cs index efd6c0a3..5d6a4d8c 100644 --- a/SIT.Manager/Services/Install/InstallerService.cs +++ b/SIT.Manager/Services/Install/InstallerService.cs @@ -698,14 +698,14 @@ public async Task InstallSit(GithubRelease selectedVersion, string targetInstall } // Find Assembly-CSharp file - var assemblyCSharpFiles = Directory.GetFiles(coreFilesPath, "Assembly-CSharp.dll"); + var assemblyCSharpFiles = Directory.GetFiles(coreFilesPath, "*Assembly-CSharp.dll"); if (assemblyCSharpFiles.Length == 0) throw new IndexOutOfRangeException("No Assembly-CSharp found in download!"); if (assemblyCSharpFiles.Length > 1) throw new IndexOutOfRangeException("There are more than one Assembly-CSharp files found!"); // Find StayInTarkov.dll - var sitFiles = Directory.GetFiles(coreFilesPath, "StayInTarkov.dll"); + var sitFiles = Directory.GetFiles(coreFilesPath, "*StayInTarkov.dll"); if (sitFiles.Length == 0) throw new IndexOutOfRangeException("No StayInTarkov.dll found in download!"); if (sitFiles.Length > 1)