diff --git a/BepInEx.Patcher/BepInEx.Patcher.csproj b/BepInEx.Patcher/BepInEx.Patcher.csproj index 518fa45..db8fa92 100644 --- a/BepInEx.Patcher/BepInEx.Patcher.csproj +++ b/BepInEx.Patcher/BepInEx.Patcher.csproj @@ -19,7 +19,7 @@ BepInEx.Patcher.Program - + true ..\bin\patcher\ TRACE @@ -29,29 +29,10 @@ prompt MinimumRecommendedRules.ruleset - - true - ..\bin\patcher\ - TRACE;UNITY_2018 - true - embedded - AnyCPU - prompt - MinimumRecommendedRules.ruleset - ..\packages\Mono.Cecil.0.10.3\lib\net35\Mono.Cecil.dll - - ..\packages\Mono.Cecil.0.10.3\lib\net35\Mono.Cecil.Mdb.dll - - - ..\packages\Mono.Cecil.0.10.3\lib\net35\Mono.Cecil.Pdb.dll - - - ..\packages\Mono.Cecil.0.10.3\lib\net35\Mono.Cecil.Rocks.dll - @@ -61,6 +42,7 @@ + @@ -76,16 +58,4 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/BepInEx.Patcher/ILRepack.targets b/BepInEx.Patcher/ILRepack.targets new file mode 100644 index 0000000..48b3f42 --- /dev/null +++ b/BepInEx.Patcher/ILRepack.targets @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/BepInEx.Patcher/Program.cs b/BepInEx.Patcher/Program.cs index 187168a..f3c7b82 100644 --- a/BepInEx.Patcher/Program.cs +++ b/BepInEx.Patcher/Program.cs @@ -26,6 +26,14 @@ namespace BepInEx.Patcher Console.ResetColor(); } + static string GetUnityEngineAssembly(string managedDir) + { + var path = Path.Combine(managedDir, "UnityEngine.CoreModule.dll"); + if (File.Exists(path)) + return path; + return Path.Combine(managedDir, "UnityEngine.dll"); + } + static void Main(string[] args) { Console.WriteLine($"BepInEx Patcher v{Assembly.GetExecutingAssembly().GetName().Version}"); @@ -43,12 +51,7 @@ namespace BepInEx.Patcher string managedDir = Environment.CurrentDirectory + $@"\{gameName}_Data\Managed"; -#if UNITY_2018 - string unityOutputDLL = Path.GetFullPath($"{managedDir}\\UnityEngine.CoreModule.dll"); -#else - string unityOutputDLL = Path.GetFullPath($"{managedDir}\\UnityEngine.dll"); -#endif - + string unityOutputDLL = GetUnityEngineAssembly(managedDir); if (!Directory.Exists(managedDir) || !File.Exists(unityOutputDLL)) continue; @@ -101,11 +104,7 @@ namespace BepInEx.Patcher AssemblyResolver = defaultResolver }; -#if UNITY_2018 - string unityBackupDLL = Path.GetFullPath($"{managedDir}\\UnityEngine.CoreModule.dll.bak"); -#else - string unityBackupDLL = Path.GetFullPath($"{managedDir}\\UnityEngine.dll.bak"); -#endif + string unityBackupDLL = $"{GetUnityEngineAssembly(managedDir)}.bak"; //determine which assembly to use as a base AssemblyDefinition unity = AssemblyDefinition.ReadAssembly(unityOutputDLL, rp); diff --git a/BepInEx.Preloader/BepInEx.Preloader.csproj b/BepInEx.Preloader/BepInEx.Preloader.csproj index ac123d9..1692a76 100644 --- a/BepInEx.Preloader/BepInEx.Preloader.csproj +++ b/BepInEx.Preloader/BepInEx.Preloader.csproj @@ -13,7 +13,7 @@ 512 true - + none true ..\bin\ @@ -22,15 +22,6 @@ 4 ..\bin\BepInEx.Preloader.xml - - ..\bin\ - TRACE;UNITY_2018 - true - none - AnyCPU - prompt - MinimumRecommendedRules.ruleset - ..\packages\Mono.Cecil.0.10.3\lib\net35\Mono.Cecil.dll diff --git a/BepInEx.Preloader/Preloader.cs b/BepInEx.Preloader/Preloader.cs index 7eb3240..56d118e 100644 --- a/BepInEx.Preloader/Preloader.cs +++ b/BepInEx.Preloader/Preloader.cs @@ -52,12 +52,9 @@ namespace BepInEx.Preloader Logger.Sources.Add(TraceLogSource.CreateSource()); PreloaderLog = new PreloaderConsoleListener(ConfigPreloaderCOutLogging.Value); - Logger.Listeners.Add(PreloaderLog); - string consoleTile = $"BepInEx {typeof(Paths).Assembly.GetName().Version} - {Process.GetCurrentProcess().ProcessName}"; - ConsoleWindow.Title = consoleTile; Logger.LogMessage(consoleTile); @@ -67,16 +64,13 @@ namespace BepInEx.Preloader if (attributes.Length > 0) { var attribute = (BuildInfoAttribute)attributes[0]; - Logger.LogMessage(attribute.Info); } Logger.LogInfo($"Running under Unity v{FileVersionInfo.GetVersionInfo(Paths.ExecutablePath).FileVersion}"); Logger.LogInfo($"CLR runtime version: {Environment.Version}"); - Logger.LogMessage("Preloader started"); - AssemblyPatcher.AddPatcher(new PatcherPlugin { TargetDLLs = () => new[] { ConfigEntrypointAssembly.Value }, @@ -88,10 +82,7 @@ namespace BepInEx.Preloader Logger.LogInfo($"{AssemblyPatcher.PatcherPlugins.Count} patcher plugin(s) loaded"); - AssemblyPatcher.PatchAndLoad(Paths.ManagedPath); - - AssemblyPatcher.DisposePatchers(); diff --git a/BepInEx.sln b/BepInEx.sln index 9d302f8..d9a254a 100644 --- a/BepInEx.sln +++ b/BepInEx.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2027 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28922.388 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx", "BepInEx\BepInEx.csproj", "{4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}" EndProject @@ -29,42 +29,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoMod.Utils", "submodules EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Legacy|Any CPU = Legacy|Any CPU - v2018|Any CPU = v2018|Any CPU + Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}.Legacy|Any CPU.ActiveCfg = Legacy|Any CPU - {4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}.Legacy|Any CPU.Build.0 = Legacy|Any CPU - {4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}.v2018|Any CPU.ActiveCfg = v2018|Any CPU - {4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}.v2018|Any CPU.Build.0 = v2018|Any CPU - {DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Legacy|Any CPU.ActiveCfg = Legacy|Any CPU - {DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Legacy|Any CPU.Build.0 = Legacy|Any CPU - {DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.v2018|Any CPU.ActiveCfg = v2018|Any CPU - {DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.v2018|Any CPU.Build.0 = v2018|Any CPU - {6E6BC1E5-5BE8-4566-B3AE-52C4CB218AEB}.Legacy|Any CPU.ActiveCfg = Release|Any CPU - {6E6BC1E5-5BE8-4566-B3AE-52C4CB218AEB}.Legacy|Any CPU.Build.0 = Release|Any CPU - {6E6BC1E5-5BE8-4566-B3AE-52C4CB218AEB}.v2018|Any CPU.ActiveCfg = Release|Any CPU - {6E6BC1E5-5BE8-4566-B3AE-52C4CB218AEB}.v2018|Any CPU.Build.0 = Release|Any CPU - {54161CFE-FF42-4DDE-B161-3A49545DB5CD}.Legacy|Any CPU.ActiveCfg = Release|Any CPU - {54161CFE-FF42-4DDE-B161-3A49545DB5CD}.Legacy|Any CPU.Build.0 = Release|Any CPU - {54161CFE-FF42-4DDE-B161-3A49545DB5CD}.v2018|Any CPU.ActiveCfg = Release|Any CPU - {54161CFE-FF42-4DDE-B161-3A49545DB5CD}.v2018|Any CPU.Build.0 = Release|Any CPU - {A15D6EE6-F954-415B-8605-8A8470CC87DC}.Legacy|Any CPU.ActiveCfg = Release|Any CPU - {A15D6EE6-F954-415B-8605-8A8470CC87DC}.Legacy|Any CPU.Build.0 = Release|Any CPU - {A15D6EE6-F954-415B-8605-8A8470CC87DC}.v2018|Any CPU.ActiveCfg = Release|Any CPU - {A15D6EE6-F954-415B-8605-8A8470CC87DC}.v2018|Any CPU.Build.0 = Release|Any CPU - {F7ABBE07-C02F-4F7C-BF6E-C6656BF588CA}.Legacy|Any CPU.ActiveCfg = Legacy|Any CPU - {F7ABBE07-C02F-4F7C-BF6E-C6656BF588CA}.Legacy|Any CPU.Build.0 = Legacy|Any CPU - {F7ABBE07-C02F-4F7C-BF6E-C6656BF588CA}.v2018|Any CPU.ActiveCfg = v2018|Any CPU - {F7ABBE07-C02F-4F7C-BF6E-C6656BF588CA}.v2018|Any CPU.Build.0 = v2018|Any CPU - {D0C584C0-81D7-486E-B70E-D7F9256E0909}.Legacy|Any CPU.ActiveCfg = Release|Any CPU - {D0C584C0-81D7-486E-B70E-D7F9256E0909}.Legacy|Any CPU.Build.0 = Release|Any CPU - {D0C584C0-81D7-486E-B70E-D7F9256E0909}.v2018|Any CPU.ActiveCfg = Release|Any CPU - {D0C584C0-81D7-486E-B70E-D7F9256E0909}.v2018|Any CPU.Build.0 = Release|Any CPU - {1839CFE2-3DB0-45A8-B03D-9AA797479A3A}.Legacy|Any CPU.ActiveCfg = Release|Any CPU - {1839CFE2-3DB0-45A8-B03D-9AA797479A3A}.Legacy|Any CPU.Build.0 = Release|Any CPU - {1839CFE2-3DB0-45A8-B03D-9AA797479A3A}.v2018|Any CPU.ActiveCfg = Release|Any CPU - {1839CFE2-3DB0-45A8-B03D-9AA797479A3A}.v2018|Any CPU.Build.0 = Release|Any CPU + {4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}.Release|Any CPU.Build.0 = Release|Any CPU + {DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Release|Any CPU.Build.0 = Release|Any CPU + {6E6BC1E5-5BE8-4566-B3AE-52C4CB218AEB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E6BC1E5-5BE8-4566-B3AE-52C4CB218AEB}.Release|Any CPU.Build.0 = Release|Any CPU + {54161CFE-FF42-4DDE-B161-3A49545DB5CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54161CFE-FF42-4DDE-B161-3A49545DB5CD}.Release|Any CPU.Build.0 = Release|Any CPU + {A15D6EE6-F954-415B-8605-8A8470CC87DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A15D6EE6-F954-415B-8605-8A8470CC87DC}.Release|Any CPU.Build.0 = Release|Any CPU + {F7ABBE07-C02F-4F7C-BF6E-C6656BF588CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7ABBE07-C02F-4F7C-BF6E-C6656BF588CA}.Release|Any CPU.Build.0 = Release|Any CPU + {D0C584C0-81D7-486E-B70E-D7F9256E0909}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0C584C0-81D7-486E-B70E-D7F9256E0909}.Release|Any CPU.Build.0 = Release|Any CPU + {1839CFE2-3DB0-45A8-B03D-9AA797479A3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1839CFE2-3DB0-45A8-B03D-9AA797479A3A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BepInEx/BepInEx.csproj b/BepInEx/BepInEx.csproj index 0c24fef..013d084 100644 --- a/BepInEx/BepInEx.csproj +++ b/BepInEx/BepInEx.csproj @@ -13,7 +13,7 @@ true - + AnyCPU none true @@ -26,14 +26,6 @@ - - ..\bin\ - TRACE;UNITY_2018 - true - AnyCPU - prompt - MinimumRecommendedRules.ruleset - ..\packages\Mono.Cecil.0.10.3\lib\net35\Mono.Cecil.dll