File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed
Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Linq ;
45using System . Reflection ;
56using BepInEx . Logging ;
67using BepInEx . Preloader . Core . Patching ;
@@ -19,7 +20,28 @@ public override IList<IPluginLoadContext> GetPatchers()
1920 {
2021 try
2122 {
22- AssemblyLocationsByFilename . Add ( Path . GetFileNameWithoutExtension ( dll ) , Path . GetDirectoryName ( dll ) ) ;
23+ var filename = Path . GetFileNameWithoutExtension ( dll ) ;
24+ var foundDirectory = Path . GetDirectoryName ( dll ) ;
25+
26+ // Prioritize the shallowest path of each assembly name
27+ if ( AssemblyLocationsByFilename . TryGetValue ( filename , out var existingDirectory ) )
28+ {
29+ int levelExistingDirectory = existingDirectory ? . Count ( x => x == Path . DirectorySeparatorChar ) ?? 0 ;
30+ int levelFoundDirectory = foundDirectory ? . Count ( x => x == Path . DirectorySeparatorChar ) ?? 0 ;
31+
32+ bool shallowerPathFound = levelExistingDirectory > levelFoundDirectory ;
33+ Log . LogWarning ( $ "Found duplicate assemblies filenames: { filename } was found at { foundDirectory } " +
34+ $ "while it exists already at { AssemblyLocationsByFilename [ filename ] } . " +
35+ $ "Only the { ( shallowerPathFound ? "first" : "second" ) } will be examined and resolved") ;
36+
37+ if ( levelExistingDirectory > levelFoundDirectory )
38+ AssemblyLocationsByFilename [ filename ] = foundDirectory ;
39+ }
40+ else
41+ {
42+ AssemblyLocationsByFilename . Add ( filename , foundDirectory ) ;
43+ }
44+
2345 loadContexts . Add ( new BepInExPatcherLoadContext
2446 {
2547 AssemblyHash = File . GetLastWriteTimeUtc ( dll ) . ToString ( "O" ) ,
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Linq ;
45using System . Reflection ;
56using BepInEx . Logging ;
67
@@ -18,7 +19,28 @@ public override IList<IPluginLoadContext> GetPlugins()
1819 {
1920 try
2021 {
21- AssemblyLocationsByFilename . Add ( Path . GetFileNameWithoutExtension ( dll ) , Path . GetDirectoryName ( dll ) ) ;
22+ var filename = Path . GetFileNameWithoutExtension ( dll ) ;
23+ var foundDirectory = Path . GetDirectoryName ( dll ) ;
24+
25+ // Prioritize the shallowest path of each assembly name
26+ if ( AssemblyLocationsByFilename . TryGetValue ( filename , out var existingDirectory ) )
27+ {
28+ int levelExistingDirectory = existingDirectory ? . Count ( x => x == Path . DirectorySeparatorChar ) ?? 0 ;
29+ int levelFoundDirectory = foundDirectory ? . Count ( x => x == Path . DirectorySeparatorChar ) ?? 0 ;
30+
31+ bool shallowerPathFound = levelExistingDirectory > levelFoundDirectory ;
32+ Logger . LogWarning ( $ "Found duplicate assemblies filenames: { filename } was found at { foundDirectory } " +
33+ $ "while it exists already at { AssemblyLocationsByFilename [ filename ] } . " +
34+ $ "Only the { ( shallowerPathFound ? "first" : "second" ) } will be examined and resolved") ;
35+
36+ if ( levelExistingDirectory > levelFoundDirectory )
37+ AssemblyLocationsByFilename [ filename ] = foundDirectory ;
38+ }
39+ else
40+ {
41+ AssemblyLocationsByFilename . Add ( filename , foundDirectory ) ;
42+ }
43+
2244 loadContexts . Add ( new BepInExPluginLoadContext
2345 {
2446 AssemblyHash = File . GetLastWriteTimeUtc ( dll ) . ToString ( "O" ) ,
You can’t perform that action at this time.
0 commit comments