[change] 检查Settings中热更新程序集列表配置中程序集名不能为空

[fix] 修复当某个热更新程序集正好是另一个AOT程序集后缀时,由于只对比字符串尾部,意外将该AOT程序集也过滤的bug
main
walon 2023-07-21 18:05:12 +08:00
parent 8a95fd57f5
commit a9f5608ecf
1 changed files with 20 additions and 8 deletions

View File

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