fix: accept schema-2 composite module manifests

This commit is contained in:
codex
2026-08-10 11:02:22 +03:00
parent 4a84c268f8
commit 4a351d9b44
3 changed files with 5 additions and 3 deletions
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0" Name="P_Rec_Annot" Description="P_Rec_Annot Plant 3D 2026" AppVersion="0.2.9" ProductCode="b455ee6eaed79d76f084846a60ce3284" Author="NBIM"> <ApplicationPackage SchemaVersion="1.0" Name="P_Rec_Annot" Description="P_Rec_Annot Plant 3D 2026" AppVersion="0.2.10" ProductCode="b455ee6eaed79d76f084846a60ce3284" Author="NBIM">
<Components> <Components>
<!-- SeriesMin/SeriesMax and platform token are pending official/runtime verification. --> <!-- SeriesMin/SeriesMax and platform token are pending official/runtime verification. -->
<RuntimeRequirements OS="Win64" /> <RuntimeRequirements OS="Win64" />
@@ -14,7 +14,9 @@ internal static class CompositeModuleManifest
var path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(assemblyPath)!, "..", "module-manifest.json")); var path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(assemblyPath)!, "..", "module-manifest.json"));
if (!File.Exists(path)) throw new InvalidOperationException("COMPOSITE_MODULE_MANIFEST_MISSING"); if (!File.Exists(path)) throw new InvalidOperationException("COMPOSITE_MODULE_MANIFEST_MISSING");
var manifest = JsonSerializer.Deserialize<CompositeManifest>(File.ReadAllText(path), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }) ?? throw new InvalidOperationException("COMPOSITE_MODULE_MANIFEST_INVALID"); var manifest = JsonSerializer.Deserialize<CompositeManifest>(File.ReadAllText(path), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }) ?? throw new InvalidOperationException("COMPOSITE_MODULE_MANIFEST_INVALID");
if (manifest.SchemaVersion != 1 || !string.Equals(manifest.Package, "P_Rec_Annot", StringComparison.Ordinal) || manifest.Modules.Count == 0) throw new InvalidOperationException("COMPOSITE_MODULE_MANIFEST_INVALID"); // Schema 2 adds the package-wide file manifest while preserving the
// required composite module/assembly contract consumed here.
if (manifest.SchemaVersion is not (1 or 2) || !string.Equals(manifest.Package, "P_Rec_Annot", StringComparison.Ordinal) || manifest.Modules.Count == 0) throw new InvalidOperationException("COMPOSITE_MODULE_MANIFEST_INVALID");
foreach (var item in manifest.Assemblies.Where(value => value.Required)) foreach (var item in manifest.Assemblies.Where(value => value.Required))
{ {
var file = Path.Combine(Path.GetDirectoryName(assemblyPath)!, item.Name); var file = Path.Combine(Path.GetDirectoryName(assemblyPath)!, item.Name);
@@ -16,6 +16,6 @@ $moduleManifestPath=Join-Path $bundleRoot 'Contents\module-manifest.json'
$files=Get-ChildItem $bundleRoot -Recurse -File | Where-Object { $_.FullName -ne $moduleManifestPath } | Sort-Object FullName | ForEach-Object { $files=Get-ChildItem $bundleRoot -Recurse -File | Where-Object { $_.FullName -ne $moduleManifestPath } | Sort-Object FullName | ForEach-Object {
[ordered]@{ relativePath=$_.FullName.Substring($bundleRoot.Length + 1).Replace('\','/'); sha256=(Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant(); required=$true } [ordered]@{ relativePath=$_.FullName.Substring($bundleRoot.Length + 1).Replace('\','/'); sha256=(Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant(); required=$true }
} }
$manifest=[ordered]@{ schemaVersion=2; package='P_Rec_Annot'; version='0.2.9'; modules=$modules; assemblies=$assemblies; files=$files } $manifest=[ordered]@{ schemaVersion=2; package='P_Rec_Annot'; version='0.2.10'; modules=$modules; assemblies=$assemblies; files=$files }
$manifest | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $bundleRoot 'Contents\module-manifest.json') -Encoding utf8 $manifest | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $bundleRoot 'Contents\module-manifest.json') -Encoding utf8
Write-Host 'Bundle assembly build completed; deployment is intentionally not performed.' Write-Host 'Bundle assembly build completed; deployment is intentionally not performed.'