Skip to content

Commit 3a46743

Browse files
Merge pull request #40 from wherget/msbuild-task-improvements
2 parents ad71503 + 31788ba commit 3a46743

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

NetcodePatcher.MSBuild.Tasks/NetcodePatchTask.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class NetcodePatchTask : Task
3434
public override bool Execute()
3535
{
3636
Serilog.Log.Logger = new LoggerConfiguration()
37-
.MinimumLevel.Information()
37+
.MinimumLevel.Debug()
3838
.WriteTo.MSBuildTask(this)
3939
.CreateLogger();
4040

@@ -43,6 +43,12 @@ public override bool Execute()
4343
.InformationalVersion;
4444
Serilog.Log.Information("Initializing NetcodePatcher v{Version:l}", toolVersion);
4545

46+
if (Patch.Length < 1)
47+
{
48+
Serilog.Log.Information("No targets specified for Netcode patching. NetcodePatcher done.");
49+
return true;
50+
}
51+
4652
var noOverwrite = false;
4753
if (!string.IsNullOrEmpty(NoOverwrite))
4854
{
@@ -93,6 +99,7 @@ void RunPatch(ITaskItem patchSpecifier)
9399
outputPath = Path.Combine(outputPath, noOverwrite ? $"{Path.GetFileNameWithoutExtension(pluginAssembly.Name)}_patched{Path.GetExtension(pluginAssembly.Name)}" : pluginAssembly.Name);
94100
}
95101

102+
Serilog.Log.Information("Processing : {input}", inputPath);
96103
patchMethod.Invoke(null, [inputPath, outputPath, ReferenceAssemblyPaths.Select(info => info.ItemSpec).ToArray()]);
97104
}
98105

NetcodePatcher.Tools.Common/PatcherLoadContext.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Reflection;
66
using System.Runtime.Loader;
7+
using Serilog;
78

89
namespace NetcodePatcher.Tools.Common;
910

@@ -27,7 +28,16 @@ public PatcherLoadContext(string name, PatcherConfiguration configuration) : bas
2728
if (assemblyName.Name is null) return null;
2829

2930
if (SharedDependencyAssemblyNames.Contains(assemblyName.Name))
30-
return Default.LoadFromAssemblyName(assemblyName);
31+
{
32+
string? sharedPath = ResolveAssemblyToPath(assemblyName);
33+
if (sharedPath is null)
34+
{
35+
Log.Debug("Shared dependency {SharedName} not found in {CommonDir} or {SharedDir}, trying to load from system", assemblyName, _configuration.PatcherCommonAssemblyDir, _configuration.PatcherNetcodeSpecificAssemblyDir);
36+
return Default.LoadFromAssemblyName(assemblyName);
37+
}
38+
Log.Debug("Shared Dependency {SharedName} loading from {Directory}", assemblyName, sharedPath);
39+
return Default.LoadFromAssemblyPath(sharedPath);
40+
}
3141

3242
string? assemblyPath = ResolveAssemblyToPath(assemblyName);
3343
if (assemblyPath is null) return null;

0 commit comments

Comments
 (0)