fix(installer): complete context bundle roots
Publish UPM package / publish (push) Successful in 2s

This commit is contained in:
2026-08-26 13:22:01 +08:00
parent c42d24bcde
commit 7096459763
4 changed files with 36 additions and 4 deletions
@@ -36,6 +36,12 @@ public static class ShrinkInstallerDevelopmentValidation
?.GetValue(null) as IEnumerable;
Require(Count(packages) == 20, "包目录数量不是 20。");
Require(Count(bundles) == 8, "推荐组合数量不是 8。");
Require(BundleContainsInstallRoot(bundles, "基础应用(推荐)",
"com.cneicy.shrink-context-eventbus-adapter"),
"基础应用组合没有显式安装 Context 事件适配。");
Require(BundleContainsInstallRoot(bundles, "常用完整套件",
"com.cneicy.shrink-context-eventbus-adapter"),
"常用完整套件没有显式安装 Context 事件适配。");
}
finally
{
@@ -60,6 +66,32 @@ public static class ShrinkInstallerDevelopmentValidation
return count;
}
private static bool BundleContainsInstallRoot(IEnumerable bundles, string bundleName, string packageName)
{
foreach (var bundle in bundles)
{
var bundleType = bundle.GetType();
if (!string.Equals(bundleType.GetProperty("DisplayName")?.GetValue(bundle) as string, bundleName,
StringComparison.Ordinal))
continue;
var roots = bundleType.GetProperty("InstallRoots")?.GetValue(bundle) as IEnumerable;
if (roots == null)
return false;
foreach (var root in roots)
{
var value = root.GetType().GetProperty("PackageName")?.GetValue(root) as string;
if (string.Equals(value, packageName, StringComparison.Ordinal))
return true;
}
return false;
}
return false;
}
private static Type FindType(string fullName) => AppDomain.CurrentDomain.GetAssemblies()
.Select(assembly => assembly.GetType(fullName, false))
.FirstOrDefault(type => type != null)