Newer Version Available

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

Generate a Package Version

A package version is a fixed snapshot of the package contents and related metadata. The package version 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 located in the package’s main directory.

How Many 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.

1sfdx force:limits:api:display

Look for the Package2VersionCreates entry.

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

Create a 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.

1sfdx force:package:version:create --package "Expenser App" --installationkey “HIF83kS8kS7C” \
2--definitionfile 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

It can be a long-running process to create a package version, depending on the package size and other variables. You can easily view the status and monitor progress.

1sfdx force:package:version:create:report --packagecreaterequestid 08cxx00000000YDAAY

The output shows details about the request.

1=== Package Version Create Request 
2NAME                            VALUE
3─────────────────────────────   ────────────────────
4Version Create Request Id       08cB00000004CBxIAM 
5Status                          InProgress 
6Package Id                      0HoB00000004C9hKAE 
7Package Version Id              05iB0000000CaaNIAS
8Subscriber Package Version Id   04tB0000000NOimIAG
9Tag                             git commit id 08dcfsdf
10Branch 
11CreatedDate                     2018-05-08 09:48
12Installation URL
13https://login.salesforce.com/packaging/installPackage.apexp?p0=04tB0000000NOimIAG

You can find the request ID (08c) in the initial output of force:package:version:create.

Depending on the size of the package and other variables, the create request can take several minutes. When you’ve more than one pending request to create package versions, you can view a list of all requests with this command.

1sfdx force:package:version:create:list --createdlastdays 0

Details for each request display as shown here (IDs and labels truncated).

1=== Package Version Create Requests [3] 
2ID     STATUS  PACKAGE2 ID PKG2 VERSION ID SUB PKG2 VER ID TAG BRANCH CREATED DATE === 
308c... Error   0Ho...      
408c... Success 0Ho... 05i... 04t...                                   2017-06-22 12:07 
508c... Success 0Ho... 05i... 04t...                                   2017-06-23 14:55

Skip Validation to Quickly Iterate Package Development

Iterate package development more efficiently by skipping validation of dependencies, package ancestors, and metadata during package version creation. Skipping validation reduces the time it takes to create a new package version, but you can promote only validated package versions to the released state.

1sfdx force:package:version:create --skipvalidation

In Tooling API, use the SkipValidation field on the Package2VersionCreateRequest object.

You can't specify both skip validation and code coverage, because code coverage is calculated during validation.

Note

Target a Specific Release for Your Packages During Salesforce Release Transitions

During major Salesforce release transitions, you can specify preview or previous when creating a package version. Specifying the release version for a package allows you to test upcoming features and run regression tests. Previously, you could only create package versions that matched the Salesforce release your Dev Hub org was on.

To create a package version based on the previous Salesforce release version, create a scratch definition file that contains:
1{
2    "release": "previous"
3}
Next, specify the definition file when you create your package version.
1sfdx force:package:version:create -f config/project-scratch-def.json

After your Dev Hub org is updated to the Spring ’21 release, you can create packages with the release version set to previous.

Starting in the Summer ’21 release transition, you can specify preview or previous as the release version.

Note