Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VersionAssemblyName to package manifest #14046

Merged
merged 10 commits into from
May 30, 2023

Conversation

ronaldbarendse
Copy link
Contributor

@ronaldbarendse ronaldbarendse commented Apr 1, 2023

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Currently the version in the package.manifest needs to be manually set (and kept up to date!) if you want to have it shown on the installed packages overview in the back-office and included in the telemetry data.

In most cases the package.manifest is shipped alongside an assembly (DLL), which is already versioned and with the changes in this PR, you can leave the version empty (or remove it from the JSON) and set versionAssemblyName to your package assembly name to have it automatically populated with the assembly version.

This ensures more packages will report the (correct) version and makes it easier for package authors (one less step/thing not to forget). The default dotnet new umbracopackage template will also automatically set this new property. I've also fixed an issue where the installed package overview didn't show the package version if a package migration state is already present in the database.


To test: build/pack Umbraco from the repository root, install the newly created package template, create/pack a new Umbraco package project and add that to the Umbraco.Web.UI project using:

dotnet pack --configuration Release --output build.out
dotnet new install build.out\Umbraco.Templates.*.nupkg
dotnet new umbracopackage --name Umbraco.Community.UmbracoPackage --output build.out\Umbraco.Community.UmbracoPackage
dotnet pack build.out\Umbraco.Community.UmbracoPackage --configuration Release --output build.out -p:EnablePackageValidation=false
dotnet add src\Umbraco.Web.UI package Umbraco.Community.UmbracoPackage --source build.out --prerelease

Next up, build the Umbraco.Web.UI project and start the application. You'll see the version is populated (instead of Unknown):

Packages - Installed


After testing, you can clean up using:

dotnet clean src\Umbraco.Web.UI
dotnet remove src\Umbraco.Web.UI package Umbraco.Community.UmbracoPackage
dotnet new uninstall Umbraco.Templates

# Optionally, if you also want the NuGet packages removed from your local cache:
dotnet nuget locals --clear all

@ronaldbarendse
Copy link
Contributor Author

I've ensured the listed installed packages that only have a package migration plan will now use the version from the assembly they're defined in. So adding the following class into the example project (created above):

using Umbraco.Cms.Core.Packaging;

public class UmbracoPackage2MigrationPlan : PackageMigrationPlan
{
    public UmbracoPackage2MigrationPlan()
        : base("Umbraco.Community.UmbracoPackage2")
    {
    }

    protected override void DefinePlan()
    {
    }
}

Will result in listing Umbraco.Community.UmbracoPackage2 with the same version:

Installed packages

@ronaldbarendse ronaldbarendse changed the title Add VersionAssemblyName to package manifest Add VersionAssemblyName to package manifest May 23, 2023
Copy link
Member

@bergmania bergmania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but we need to add the default to the RCL template too

@ronaldbarendse ronaldbarendse changed the base branch from contrib to release/12.0 May 30, 2023 10:59
@ronaldbarendse
Copy link
Contributor Author

Looks good, but we need to add the default to the RCL template too

I've merged the changes that added the new Umbraco Package RCL template, updated that package manifest as well and updated the base branch to target the v12 release 👍🏻

@bergmania
Copy link
Member

Great @ronaldbarendse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants