Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion NetcodePatcher.MSBuild.Tasks/NetcodePatchTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class NetcodePatchTask : Task
public override bool Execute()
{
Serilog.Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Debug()
.WriteTo.MSBuildTask(this)
.CreateLogger();

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

if (Patch.Length < 1)
{
Serilog.Log.Information("No targets specified for Netcode patching. NetcodePatcher done.");
return true;
}

var noOverwrite = false;
if (!string.IsNullOrEmpty(NoOverwrite))
{
Expand Down Expand Up @@ -93,6 +99,7 @@ void RunPatch(ITaskItem patchSpecifier)
outputPath = Path.Combine(outputPath, noOverwrite ? $"{Path.GetFileNameWithoutExtension(pluginAssembly.Name)}_patched{Path.GetExtension(pluginAssembly.Name)}" : pluginAssembly.Name);
}

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

Expand Down
12 changes: 11 additions & 1 deletion NetcodePatcher.Tools.Common/PatcherLoadContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using Serilog;

namespace NetcodePatcher.Tools.Common;

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

if (SharedDependencyAssemblyNames.Contains(assemblyName.Name))
return Default.LoadFromAssemblyName(assemblyName);
{
string? sharedPath = ResolveAssemblyToPath(assemblyName);
if (sharedPath is null)
{
Log.Debug("Shared dependency {SharedName} not found in {CommonDir} or {SharedDir}, trying to load from system", assemblyName, _configuration.PatcherCommonAssemblyDir, _configuration.PatcherNetcodeSpecificAssemblyDir);
return Default.LoadFromAssemblyName(assemblyName);
}
Log.Debug("Shared Dependency {SharedName} loading from {Directory}", assemblyName, sharedPath);
return Default.LoadFromAssemblyPath(sharedPath);
}

string? assemblyPath = ResolveAssemblyToPath(assemblyName);
if (assemblyPath is null) return null;
Expand Down