Put your package in the installed package list in Umbraco 9

kevinjump

Kevin Jump

Posted on February 20, 2022

Put your package in the installed package list in Umbraco 9

In Umbraco v8 if you installed your package via the package manager it would appear in the list of installed packages in the packages dashboard.

in v9 all packages are installed via nuget. but wait some packages still appear in the installed package list ?

Image description

how do they do that ?

well the short answer is package migrations.

Package Migration

if your package has a package migration it will appear in the list. So even if you don't have anything you need to do in a migration you can put a blank one in to get into the list

uSync's basic package migration

public class uSyncMigrationPlan : PackageMigrationPlan
{
    public uSyncMigrationPlan() :
        base(uSync.PackageName)
    { }

    protected override void DefinePlan()
    {
        To<SetupuSync>(new Guid("dd231cf5-5560-4f42-85a0-0ff8d8f37eb3"));
    }
}

public class SetupuSync : PackageMigrationBase
{
    public SetupuSync(
        IPackagingService packagingService, 
        IMediaService mediaService, 
        MediaFileManager mediaFileManager, 
        MediaUrlGeneratorCollection mediaUrlGenerators, 
        IShortStringHelper shortStringHelper, 
        IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
        IMigrationContext context) 
        : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider, context)
    {
    }

    protected override void Migrate()
    {
        // we don't actually need to do anything, but this means we end up
        // on the list of installed packages. 
    }
}
Enter fullscreen mode Exit fullscreen mode

here you just need a unique GUid value for your package
and a package name (uSync already had the name in a constant uSync.PackageName)

That's it

you don't need to register your package migration, it is auto discovered by Umbraco and the name will mean your package will appear in the backoffice

💖 💪 🙅 🚩
kevinjump
Kevin Jump

Posted on February 20, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related