Skip to content

Commit

Permalink
Fixed an issue with .NET Bundle Extraction attempting to extract to a…
Browse files Browse the repository at this point in the history
… folder of the same name as the executable
  • Loading branch information
HerpDerpinstine committed Dec 8, 2024
1 parent 095c3f4 commit f059fd2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Dependencies/Il2CppAssemblyGenerator/FileHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using MelonLoader.Lemons.Cryptography;

namespace MelonLoader.Il2CppAssemblyGenerator
{
Expand Down
1 change: 0 additions & 1 deletion Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ internal override bool Execute()

], false, new Dictionary<string, string>() {
{"NO_COLOR", "1"},
{"DOTNET_BUNDLE_EXTRACT_BASE_DIR", BaseFolder }
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ internal bool Execute(string[] args, bool parenthesize_args = true, Dictionary<s
Core.Logger.Msg($"Executing {Name}...");
try
{
string tempFolder = Path.Combine(Path.GetDirectoryName(ExeFilePath),
$"{Path.GetFileNameWithoutExtension(ExeFilePath)}_Temp");
if (!Directory.Exists(tempFolder))
Directory.CreateDirectory(tempFolder);

ResetEvent_Output = new AutoResetEvent(false);
ResetEvent_Error = new AutoResetEvent(false);

Expand All @@ -64,10 +69,9 @@ internal bool Execute(string[] args, bool parenthesize_args = true, Dictionary<s

if (environment != null)
{
processStartInfo.EnvironmentVariables["DOTNET_BUNDLE_EXTRACT_BASE_DIR"] = tempFolder;
foreach (var kvp in environment)
{
processStartInfo.EnvironmentVariables[kvp.Key] = kvp.Value;
}
}

Core.Logger.Msg("\"" + ExeFilePath + "\" " + processStartInfo.Arguments);
Expand All @@ -88,6 +92,10 @@ internal bool Execute(string[] args, bool parenthesize_args = true, Dictionary<s
ResetEvent_Error.WaitOne();

SetProcessId(0);

if (Directory.Exists(tempFolder))
Directory.Delete(tempFolder, true);

return process.ExitCode == 0;
}
catch (Exception ex)
Expand Down

0 comments on commit f059fd2

Please sign in to comment.