Error when I create a package using the Umbraco Package RCL Visual Studio Template

I have a problem when I try to create a package using the Umbraco Package RCL Visual Studio Template. I will try to describe exactly what I do in order to create the package.

I created two projects. The first is called MyUmbraco using the “Umbraco Project (Umbraco HQ) v11.4.0” template and the second is called MyTools using the “Umbraco Package RCL (Umbraco HQ) v11.4.0” template enabling the “Support pages and views” option. I added a reference of the MyTools project to the MyUmbraco project.

I define the package manifest using the following code inside the ubmraco package project

using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Manifest;

namespace MyTools;

internal class MyToolsManifestFilter : IManifestFilter
{
    public void Filter(List<PackageManifest> manifests)
    {
        manifests.Add(new PackageManifest
        {
            PackageName = "MyTools"
            // I do not need scripts and css files yet
        });
    }
}

public class UmbracoPackage1Composer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.ManifestFilters().Append<MyToolsManifestFilter>();
    }
}

Now I use the “A guide to creating a custom tree in Umbraco” from the documentation (https://docs.umbraco.com/umbraco-cms/extending/section-trees/trees) in order to define a tree for my package:

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Extensions;

namespace MyTools;


[Tree("settings", "favouriteThingsAlias", TreeTitle = "Favourite Things Name", TreeGroup = "favouritesGroup", SortOrder = 5)]
public class FavouriteThingsTreeController : TreeController
{

    private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;

    public FavouriteThingsTreeController(ILocalizedTextService localizedTextService,
        UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
        IMenuItemCollectionFactory menuItemCollectionFactory,
        IEventAggregator eventAggregator)
        : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
    {
        _menuItemCollectionFactory = menuItemCollectionFactory ?? throw new ArgumentNullException(nameof(menuItemCollectionFactory));
    }

    protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
    {
        var nodes = new TreeNodeCollection();

        // check if we're rendering the root node's children
        if (id == Constants.System.Root.ToInvariantString())
        {
            // you can get your custom nodes from anywhere, and they can represent anything...
            Dictionary<int, string> favouriteThings = new Dictionary<int, string>();
            favouriteThings.Add(1, "Raindrops on Roses");
            favouriteThings.Add(2, "Whiskers on Kittens");
            favouriteThings.Add(3, "Skys full of Stars");
            favouriteThings.Add(4, "Warm Woolen Mittens");
            favouriteThings.Add(5, "Cream coloured Unicorns");
            favouriteThings.Add(6, "Schnitzel with Noodles");

            // loop through our favourite things and create a tree item for each one
            foreach (var thing in favouriteThings)
            {
                // add each node to the tree collection using the base CreateTreeNode method
                // it has several overloads, using here unique Id of tree item,
                // -1 is the Id of the parent node to create, eg the root of this tree is -1 by convention
                // - the querystring collection passed into this route
                // - the name of the tree node
                // - css class of icon to display for the node
                // - and whether the item has child nodes
                var node = CreateTreeNode(thing.Key.ToString(), "-1", queryStrings, thing.Value, "icon-presentation", false);
                nodes.Add(node);
            }
        }

        return nodes;
    }

    protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
    {
        // create a Menu Item Collection to return so people can interact with the nodes in your tree
        var menu = _menuItemCollectionFactory.Create();

        if (id == Constants.System.Root.ToInvariantString())
        {
            // root actions, perhaps users can create new items in this tree, or perhaps it's not a content tree, it might be a read only tree, or each node item might represent something entirely different...
            // add your menu item actions or custom ActionMenuItems
            menu.Items.Add(new CreateChildEntity(LocalizedTextService));
            // add refresh menu item (note no dialog)
            menu.Items.Add(new RefreshNode(LocalizedTextService, true));
        }
        else
        {
            // add a delete action to each individual item
            menu.Items.Add<ActionDelete>(LocalizedTextService, true, opensDialog: true);
        }

        return menu;
    }

    protected override ActionResult<TreeNode?> CreateRootNode(FormCollection queryStrings)
    {
        var rootResult = base.CreateRootNode(queryStrings);
        if (!(rootResult.Result is null))
        {
            return rootResult;
        }

        var root = rootResult.Value;

        // set the icon
        root.Icon = "icon-hearts";
        // could be set to false for a custom tree with a single node.
        root.HasChildren = true;
        //url for menu
        root.MenuUrl = null;

        return root;
    }
}

When I run my project and visit the settings section I have the following error:

Can someone tell me what is my mistake?

Thanks.


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/112078-error-when-i-create-a-package-using-the-umbraco-package-rcl-visual-studio-template