Newer Version Available

This content describes an older version of this product. View Latest

Create and Update Versions of a Second-Generation Managed Package

A package version is a fixed snapshot of the package contents and related metadata. The package version is an installable, immutable artifact that lets you manage changes and track what’s different each time you release or deploy a specific set of changes.

Before you create a package version, first verify package details, such as the package name, dependencies, and major, minor, and patch version numbers, in the sfdx-project.json file. Verify that the metadata you want to change or add in the new package version is in the package’s main directory.

How Many Managed 2GP Package Versions Can I Create Per Day?

Run this command to see how many package versions you can create per day and how many you have remaining.

1sf limits api display

Look for the Package2VersionCreates entry.

1NAME                                   REMAINING  MAXIMUM
2─────────────────────────────────────  ─────────  ─────────
3Package2VersionCreates                  23         50

Create a Managed 2GP Package Version

Create the package version with this command. Specify the package alias or ID (0Ho). You can also include a scratch definition file that contains a list of features and setting that the metadata of the package version depends on.

1sf package version create --package "Expenser App" --installation-key “HIF83kS8kS7C” \
2--definition-file config/project-scratch-def.json --wait 10

When creating a package version, specify a --wait time to run the command in non-asynchronous mode. If the package version is created within that time, the sfdx-project.json file is automatically updated with the package version information. If not, you must manually edit the project file.

Note

Use Keyword NEXT to Ensure Package Version Numbers Are Unique

To ensure your version number is unique, use the keyword NEXT when you set the version number in your sfdx-project.json file.

For example, "versionNumber": "1.2.0.NEXT".

If you don’t use NEXT, and you also forget to update the version number in your sfdx-project.json file, the new package version uses the same number as the previous package version. Although we don’t enforce uniqueness on package version numbers, every package version is assigned a unique subscriber package version ID (starts with 04t).

Update a Managed 2GP Package Version

You can update most properties of a package version from the command line. For example, you can change the package version name or description. One important exception is that you can’t change the release status.

In this example, we’re adding the tag parameter and specifying the git commit ID associated with this package version.

1sf package version update --package "Expenser App@1.3.0-5" --tag "git commit id 08dcfsdf"

After the update is complete, you’ll see output that looks like

1Successfully updated the package version. 04tB0000000KPhnIAG