Skip to content

Commit

Permalink
Fixed manifest filter after cherry picking from v13/main
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Jun 27, 2024
1 parent e597ffd commit e3f5abc
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Skybrud.Essentials.Umbraco/EssentialsManifestFilter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Reflection;
using Umbraco.Cms.Core.Manifest;

namespace Skybrud.Essentials.Umbraco;
Expand All @@ -8,9 +9,10 @@ public class EssentialsManifestFilter : IManifestFilter {

/// <inheritdoc />
public void Filter(List<PackageManifest> manifests) {
manifests.Add(new PackageManifest {

// Initialize a new manifest filter for this package
PackageManifest manifest = new() {
AllowPackageTelemetry = false,
PackageId = EssentialsPackage.Alias,
PackageName = EssentialsPackage.Name,
Version = EssentialsPackage.InformationalVersion,
Scripts = [
Expand All @@ -20,7 +22,21 @@ public void Filter(List<PackageManifest> manifests) {
Stylesheets = [
$"/App_Plugins/{EssentialsPackage.AppPlugins}/Styles/Styles.css"
]
});
};

// The "PackageId" property isn't available prior to Umbraco 12, and since the package is build against
// Umbraco 10, we need to use reflection for setting the property value for Umbraco 12+. Ideally this
// shouldn't fail, but we might at least add a try/catch to be sure
try {
PropertyInfo? property = manifest.GetType().GetProperty("PackageId");
property?.SetValue(manifest, EssentialsPackage.Alias);
} catch {
// We don't really care about the exception
}

// Append the manifest
manifests.Add(manifest);

}

}

0 comments on commit e3f5abc

Please sign in to comment.