diff --git a/Editor/BuildProcessors/FilterHotFixAssemblies.cs b/Editor/BuildProcessors/FilterHotFixAssemblies.cs index e18f075..08bb825 100644 --- a/Editor/BuildProcessors/FilterHotFixAssemblies.cs +++ b/Editor/BuildProcessors/FilterHotFixAssemblies.cs @@ -1,6 +1,7 @@ using HybridCLR.Editor.Meta; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -25,15 +26,18 @@ namespace HybridCLR.Editor.BuildProcessors return assemblies; } List allHotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved; - List allHotupdateDllFiles = SettingsUtil.HotUpdateAssemblyFilesExcludePreserved; // 检查是否重复填写 var hotUpdateDllSet = new HashSet(); foreach(var hotUpdateDll in allHotUpdateDllNames) { + if (string.IsNullOrWhiteSpace(hotUpdateDll)) + { + throw new BuildFailedException($"热更新 assembly 名不能为空"); + } if (!hotUpdateDllSet.Add(hotUpdateDll)) { - throw new Exception($"热更新 assembly:{hotUpdateDll} 在列表中重复,请除去重复条目"); + throw new BuildFailedException($"热更新 assembly:{hotUpdateDll} 在列表中重复,请除去重复条目"); } } @@ -41,16 +45,24 @@ namespace HybridCLR.Editor.BuildProcessors // 检查是否填写了正确的dll名称 foreach (var hotUpdateDllName in allHotUpdateDllNames) { - string hotUpdateDllFile = hotUpdateDllName + ".dll"; - if (assemblies.All(ass => !ass.EndsWith(hotUpdateDllFile)) && string.IsNullOrEmpty(assResolver.ResolveAssembly(hotUpdateDllName, false))) + if (assemblies.Select(Path.GetFileNameWithoutExtension).All(ass => ass != hotUpdateDllName) + && string.IsNullOrEmpty(assResolver.ResolveAssembly(hotUpdateDllName, false))) { - throw new Exception($"热更新 assembly:{hotUpdateDllFile} 不存在,请检查拼写错误"); + throw new BuildFailedException($"热更新 assembly:{hotUpdateDllName} 不存在,请检查拼写错误"); } - Debug.Log($"[FilterHotFixAssemblies] 过滤热更新assembly:{hotUpdateDllFile}"); } - + // 将热更dll从打包列表中移除 - return assemblies.Where(ass => allHotupdateDllFiles.All(dll => !ass.EndsWith(dll, StringComparison.OrdinalIgnoreCase))).ToArray(); + return assemblies.Where(ass => + { + string assName = Path.GetFileNameWithoutExtension(ass); + bool reserved = allHotUpdateDllNames.All(dll => !assName.Equals(dll, StringComparison.Ordinal)); + if (!reserved) + { + Debug.Log($"[FilterHotFixAssemblies] 过滤热更新assembly:{assName}"); + } + return reserved; + }).ToArray(); } } }